• Home
  • Ubuntu 20.04
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 20.04
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Add Multiple Hosts in phpMyAdmin

Written by Rahul, Updated on November 15, 2017

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.

phpmyadmin-multiplehosts

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

17 Comments

  1. Avatar Vinay Reply
    December 9, 2019 at 8:59 am

    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

  2. Avatar bobthehobo Reply
    September 30, 2019 at 5:37 pm

    On Ubuntu 18 this config file was under /etc/phpmyadmin/config.inc.php

  3. Avatar Oscar Reply
    August 27, 2019 at 3:48 pm

    Thanks a loot, old but gold!

  4. Avatar Raghav Bhandari Reply
    July 3, 2019 at 11:32 am

    Thank you , it worked.

  5. Avatar Alejandro Reply
    October 31, 2018 at 3:31 pm

    Thank you Very Much from Argentina

  6. Avatar nanumi Reply
    May 12, 2018 at 6:09 am

    Thanks Rahul.

  7. Avatar Terry Wong Reply
    February 13, 2018 at 5:45 am

    Very clear! Thanks for your tips. It works on my localhost envrionment.

  8. Avatar Paweł Reply
    November 15, 2017 at 8:46 am

    Rahul, thanks for your tutorial

  9. Avatar Igor Michel Reply
    November 7, 2017 at 6:17 am

    Thank you very. It works for me..

  10. Avatar Riz Reply
    March 28, 2017 at 9:28 am

    Like Irfan said, some distributions (eg. Debian or Ubuntu) store config.inc.php in /etc/phpmyadmin instead of /usr/share/phpmyadmin.

  11. Avatar SKOH Reply
    September 30, 2015 at 11:06 am

    Thanks, this with IRFAN and JPACHTA comments works for me on Ubuntu

  12. Avatar jpachta Reply
    September 17, 2015 at 12:03 pm

    Hi, thanks for sharing this solution. It works.
    Just remove extra white spaces in all string enclosed in apostrophes!

  13. Avatar makinero Reply
    May 28, 2015 at 7:23 am

    Does not work.

    • Rahul Rahul Reply
      June 1, 2015 at 4:23 pm

      Hi Makinero,

      What issue are you facing ? Which operating system are you using ?

      • Avatar Iurie Reply
        September 16, 2015 at 9:17 am

        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

    • Avatar carlo Reply
      October 15, 2017 at 9:08 am

      Good comment. Nice explanation. Nice “Roboto Slab” font btw. The sun is shining, everything is awesome. I’m not a robot!

  14. Avatar Irfan Reply
    November 5, 2014 at 9:39 am

    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.

Leave a Reply Cancel reply

Popular Posts

  • How to View or List Cron Jobs in Linux
  • How to Install PHP 8 on Ubuntu 20.04
  • How to Set Up SSH Tunnel with PuTTY
  • How to Install Tor Browser on Ubuntu 20.04
  • Issue with phpMyAdmin and PHP: Warning in ./libraries/sql.lib.php#613 count(): Parameter must be an array or an object that implements Countable”
  • How to Allow Remote Connections to MySQL
  • How to Install MySQL 8.0 on Ubuntu 20.04
  • How to Install Apache Kafka on Ubuntu 20.04
© 2013-2021 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy