We want to auto login users in phpMyAdmin. Now we have a web-interface, written in PHP. Users can login. After logging in, they can click on the SQL
link in the menu that opens phpMyAdmin. Is there a way to log them in automatically? Is it possible to set cookies for phpMyAdmin or something to let them use it?
We don’t want to turn off phpMyAdmin’s login; each user has his own MySQL user/pass combination. So we need to pass the username/password settings to phpMyAdmin.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Add code in config.inc.php below of /* Authentication type */. It exists in the root folder
$cfg['Servers'][$i]['auth_type'] = 'config'; $cfg['Servers'][$i]['user'] = 'root'; $cfg['Servers'][$i]['password'] = '';
Method 2
Edit config.inc.php
Location : /etc/phpmyadmin/config.inc.php
Find for the blow code
$cfg['Servers'][$i]['auth_type'] = 'cookie';
And replace the line of code by blow code
$cfg['Servers'][$i]['auth_type'] = 'config'; $cfg['Servers'][$i]['user'] = 'root'; $cfg['Servers'][$i]['password'] = 'your_password';
If your password null or ” the uncomment the blow line
//$cfg['Servers'][$i]['AllowNoPassword'] = TRUE;
to
$cfg['Servers'][$i]['AllowNoPassword'] = TRUE;
then it will work fine !
Method 3
You can simply post the username in a field named pma_username
and the password in pma_password
. Or, if you’re using http auth mode you can create a link with username and password like http://user:[email protected]/phpmyadmin/...
Method 4
config.inc.php
/* Authentication type */ //$_SERVER["REMOTE_ADDR"] == '::1' (**ipv6**) //$_SERVER["REMOTE_ADDR"] == '127.0.0.1' (**ipv4**) if ($_SERVER["REMOTE_ADDR"] == '::1') { $cfg['Servers'][$i]['auth_type'] = 'config'; $cfg['Servers'][$i]['user'] = 'user'; $cfg['Servers'][$i]['password'] = 'password'; } else { $cfg['Servers'][$i]['auth_type'] = 'cookie'; }
Method 5
Sometimes when working at your local environment it annoys to login each time.
To avoid it you can do the following:
Add following lines at bottom of file:
phpmyadminconfig.inc.php
$cfg['LoginCookieValidity'] = 10000; // Keep long validity :)- $cfg['Servers'][$i]['user'] = 'root'; // Your user name $cfg['Servers'][$i]['password'] = 'root'; // Your password $cfg['Servers'][$i]['auth_type'] = 'config';
After that shutdown your db server & restart again.
Now check & you will see that you will login without entering user name & password.
Method 6
Things are much easier in 2020 if you need this for development. Just set environment variables:
PMA_USER: "the-root" PMA_PASSWORD: "the-password"
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0