phpMyAdmin default configuration allows to connect to local MySQL server only, But if we have multiple database server running, then it would be great if we can choose to which server we need to connect from single phpMyAdmin installation. This how-to guide will help you to add multiple database hosts in phpMyAdmin, So we can select to which database server we need to connect from the web interface.
After installing phpMyAdmin on your Linux/Windows systems, lets use this to manage multiple hosts from one phpMyAdmin install.
First navigate to your phpMyAdmin installation directory. Directory location may be differ with your installation method. In most case we can found it on /usr/share/phpMyAdmin or /usr/share/phpmyadmin directory.
cd /usr/share/phpmyadmin cp config.sample.inc.php config.inc.php vim config.inc.php
Now add the following entries at the end of the file.
$i++; $cfg['Servers'][$i]['verbose'] = 'Database Server 2 '; $cfg['Servers'][$i]['host'] = '192.168.1.102 '; $cfg['Servers'][$i]['port'] = ''; $cfg['Servers'][$i]['socket'] = ''; $cfg['Servers'][$i]['connect_type'] = 'tcp'; $cfg['Servers'][$i]['extension'] = 'mysqli'; $cfg['Servers'][$i]['auth_type'] = 'cookie'; $cfg['Servers'][$i]['AllowNoPassword'] = false;
After adding the above entries in the configuration file and access phpMyAdmin in a web browser and you will get an option of server choice. Select server name to which you need to connect.
17 Comments
How to set Server Choice internally based on a URL , say for UAT I have abc.xyz.com , it should set to UAT , else prod
On Ubuntu 18 this config file was under /etc/phpmyadmin/config.inc.php
Thanks a loot, old but gold!
Thank you , it worked.
Thank you Very Much from Argentina
Thanks Rahul.
Very clear! Thanks for your tips. It works on my localhost envrionment.
Rahul, thanks for your tutorial
Thank you very. It works for me..
Like Irfan said, some distributions (eg. Debian or Ubuntu) store config.inc.php in /etc/phpmyadmin instead of /usr/share/phpmyadmin.
Thanks, this with IRFAN and JPACHTA comments works for me on Ubuntu
Hi, thanks for sharing this solution. It works.
Just remove extra white spaces in all string enclosed in apostrophes!
Does not work.
Hi Makinero,
What issue are you facing ? Which operating system are you using ?
Rahul, I don’t know about other distributions, but in Ubuntu, after your instructions, it was needed to copy the config.inc.php to /etc/phpmyadmin/.
cp /usr/share/phpmyadmin/config.inc.php /etc/phpmyadmin/
service apache2 restart #I don't know if this is really needed
Good comment. Nice explanation. Nice “Roboto Slab” font btw. The sun is shining, everything is awesome. I’m not a robot!
Hi Rahul
Thanks for your post, it is really nice and helpful.
But i found two things while doing the same on my localhost/phpmyadmin on my ubuntu machine.
1. The file was NOT available at the said location (/usr/share/phpMyAdmin or /usr/share/phpmyadmin). Then i created the file with the above code but nothing happened.
2. Then i updated /etc/phpmyadmin/config.inc.php with the above code and it worked!!! 🙂
Once again, thank you so much for your post.