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.
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 useyour_new_server.inc.php
for consistency.The minimal contents for a given config file would be:
As stated in another answer, you can check the /usr/share/doc/phpmyadmin/examples/config.manyhosts.inc.php file 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(s) phpMyAdmin had thought about it, they could have added the incrementing
$i
variable in the foreach that includes the files from theconf.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.[2019]: Newer PHP versions allow this more succinct alternative syntax:
I think this is the most accurate way to do it:
First setup the password:
Then disable security:
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:
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, theconfig-db.php
is changed, so 'local' changes to your file are not modifiedTherefore my conclusion was that adding an extra server below this part:
This looks like the best place.
According to the phpMyAdmin documentation you can define multiple servers in the
$cfg['Servers']
array defined in theconfig.inc.php
file.The main configuration file is stored in
/etc/phpmyadmin/config.inc.php
. This file includes the/var/lib/phpmyadmin/blowfish_secret.inc.php
/var/lib/phpmyadmin/config.inc.php
/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 usingdpkg-reconfigure -plow phpmyadmin
/etc/phpmyadmin/conf.d/*.php
Some example configuration snippets are in
/usr/share/doc/phpmyadmin/examples
includingconfig.manyhosts.inc.php
. This file can be added to/etc/phpmyadmin/conf.d
. It works by resetting thei
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
: