Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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/config.inc.php, 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

5 Answers 5

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/config.inc.php. –  Michael Lawton May 9 at 17:41
    
This config file generated by this method is then included in the main config file at /etc/phpmyadmin/config.inc.php. 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 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/config.inc.php 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'] = 'serverhost.host.tld';
 $cfg['Servers'][$i]['extension'] = 'mysqli';
//...etc

This looks like the best place.

share|improve this answer

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

share|improve this answer
2  
In a generic phpMyAdmin install, yes. But Ubuntu has its own configuration files to generate that part of the config.inc.php 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
2  
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

The main configuration file is stored in /etc/phpmyadmin/config.inc.php. This file includes the

  • Blowfish secret from /var/lib/phpmyadmin/blowfish_secret.inc.php
  • Generated config from phpMyAdmin setup script (diegueus9's method) /var/lib/phpmyadmin/config.inc.php
  • 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 config.manyhosts.inc.php. 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/config.inc.php.

If you want to do a more advanced configuration, you will probably want to change the /etc/phpmyadmin/config.inc.php 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/config.inc.php:

/* Support additional configurations */
foreach (glob('/etc/phpmyadmin/conf.d/*.php') as $filename) {
        include($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
2  
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

 
discard

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.