Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the Ubuntu way to configure phpMyAdmin so that I can use it to administer multiple MySQL servers? The database parameters are set in /etc/dbconfig-common/phpmyadmin.conf, but there's only space in there for the connection parameters for a single server. I could hack it into /etc/phpmyadmin/config-db.php and /etc/phpmyadmin/, but I assume there has to be a more elegant way.

share|improve this question
Have you ever found a sollution to do this? Did you hack into one of the files you've mentioned, or not? – Nanne Mar 31 '11 at 9:41

I think this is the most accurate way to do it:

First setup the password:

sudo htpasswd -c /etc/phpmyadmin/htpasswd.setup admin

Then disable security:

sudo pma-configure

Then go to http://yourserver/phpmyadmin/setup (here the browsers ask for auth, the user is admin and the password is what you write in first command), with that wizard you configure your servers, once is done, put the security again:

sudo pma-secure
share|improve this answer
The config file generated by this method is stored in /var/lib/phpmyadmin/ – Michael Lawton May 9 '14 at 17:41
This config file generated by this method is then included in the main config file at /etc/phpmyadmin/ The phpMyAdmin setup script is buggy on Ubuntu and doesn't load the existing configuration (forcing you to start from scratch each time you configure it). Also the configuration it generates includes stuff like the blowfish secret which is then overwritten by the main config file. You will find that the first server (1) is overwritten by the main config file, which uses the server values from config-db.php. – Michael Lawton May 11 '14 at 16:22

I have assumed the following:

  • /etc/phpmyadmin/ would be the most logical place to add the config
  • /etc/phpmyadmin/config-db.php is the location for the default (local?) config. This is, because it is a default, one db only
  • /etc/phpmyadmin/ reads the default database so it has one. At least this one is used, so you have a database. If something changes in your config, the config-db.php is changed, so 'local' changes to your file are not modified

Therefore my conclusion was that adding an extra server below this part:

/* Configure according to dbconfig-common if enabled */
if (!empty($dbname)) {
    //reading from config-db.php

//$i++ was allready done in if above
//Adding extra servers
 $cfg['Servers'][$i]['host'] = '';
 $cfg['Servers'][$i]['extension'] = 'mysqli';

This looks like the best place.

share|improve this answer

Fairly old question, but still relevant on searches.

phpMyAdmin uses plain PHP for config files, and the $cfg['Servers'] array to get the configured servers.

So the proper way is to add a new config file in /etc/phpmyadmin/conf.d for every server you want to add. It's only required to end the files name in .php to get them included, but it's a good idea to use for consistency.

The minimal contents for a given config file would be:

$cfg['Servers'][2]['host']     = 'THE_HOST';
$cfg['Servers'][2]['user']     = 'THE_USER';
$cfg['Servers'][2]['password'] = 'THE_PASSWORD';

As stated above, you can check /usr/share/doc/phpmyadmin/examples/ for more parameters.

Important: You have to increase the index (2) of the array for every new file, and avoid using 1 if you want to keep connecting to localhost.

If the guy(s) that package phpMyAdmin have thought about it, they could have added the incrementing $i variable in the foreach that includes the files from the conf.d directory, so you could just use it as the index and not worry about having to increase it manually, but sadly it's not the case. You can do it yourself though.

share|improve this answer
I tried putting the minimal content listed in /etc/phpmyadmin/conf.d/slaveA.conf.php and simply saw the contents at the top of the PHPMyAdmin page. When I catted that same contents into the bottom of it worked. Something about that include seems to be messing it up. Otherwise, this looks to be the expected way to create custom config that won't get killed in updates. – flickerfly Mar 1 at 17:07

According to the phpMyAdmin documentation you can define multiple servers in the $cfg['Servers'] array defined in the file.

share|improve this answer
In a generic phpMyAdmin install, yes. But Ubuntu has its own configuration files to generate that part of the file, and I want to know the Ubuntu way to configure it, without having to override the Ubuntu configuration. – Mike Scott Jan 4 '11 at 9:57
I see. The comments in the file say You can regenerate it using: dpkg-reconfigure -plow phpmyadmin. I assume you tried that? (won't do it on production system now) Other than that ... manually changed files should be prompted on update before being overwritten. – Carsten Thiel Jan 4 '11 at 10:06
Yes, I can regenerate the file config-db.php, but the config file from which it sources the database connection parameters (/etc/dbconfig-common/phpmyadmin.conf) only has room to configure one database server. I want to know how to configure more than one database server. – Mike Scott Jan 4 '11 at 10:21
+Mike Scott, I couldn't get $cfg['Servers'] to work in a conf.d/ file, but when I put it in it worked fine. I'm thinking there is some bug that the include statement messes with it. – flickerfly Mar 1 at 17:09

The main configuration file is stored in /etc/phpmyadmin/ This file includes the

  • Blowfish secret from /var/lib/phpmyadmin/
  • Generated config from phpMyAdmin setup script (diegueus9's method) /var/lib/phpmyadmin/
  • DB values from /etc/phpmyadmin/config-db.php which are generated from /etc/dbconfig-common/phpmyadmin.conf by /usr/sbin/dbconfig-generate-include. /etc/dbconfig-common/phpmyadmin.conf can be modified using dpkg-reconfigure -plow phpmyadmin
  • Extra configuration files from /etc/phpmyadmin/conf.d/*.php

Some example configuration snippets are in /usr/share/doc/phpmyadmin/examples including This file can be added to /etc/phpmyadmin/conf.d. It works by resetting the i variable back to 1 before creating any hosts so that it overrides the host set in /etc/phpmyadmin/

If you want to do a more advanced configuration, you will probably want to change the /etc/phpmyadmin/ file and possibly add other configuration extensions using /etc/phpmyadmin/conf.d.

To add support for additional configurations to older configuration files, you can create the directory /etc/phpmyadmin/conf.d and then add the below PHP code to the bottom of /etc/phpmyadmin/

/* Support additional configurations */
foreach (glob('/etc/phpmyadmin/conf.d/*.php') as $filename) {
share|improve this answer

This tutorial explains how you can manage multiple MySQL servers from one phpMyAdmin installation. For security reasons, communication between phpMyAdmin and any remote MySQL server is using SSL encryption

share|improve this answer
That doesn't tell me how to do it using the Ubuntu way of configuring it, so it doesn't answer the question at all. – Mike Scott Sep 21 '12 at 10:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.