phpMyAdmin: how to use it with several MySQL servers

If you have several MySQL servers it makes sense to use one phpMyAmin to manage them. ┬áTo do it just add as many server as you need to config.inc.php. In Fedora and Centos it is located in /etc/phpMyAdmin/. Here’s an example:

<?php

/* Servers configuration */
$i = 0;

/* Server: localhost [1] */
$i++;
$cfg['Servers'][$i]['verbose'] = '';
$cfg['Servers'][$i]['host'] = 10.20.90.1;
$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';

/* Server: 10.20.90.2 [2] */
$i++;
$cfg['Servers'][$i]['verbose'] = '';
$cfg['Servers'][$i]['host'] = '10.20.90.2';
$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';

/* End of servers configuration */

$cfg['blowfish_secret'] = '3242fndsnj342qljds32s';
$cfg['DefaultLang'] = 'en';
$cfg['ServerDefault'] = 0;
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';
?>

Now you can select which MySQL server to use before you logged in. For security reasons it’s always better to use only SSL hosts, non-root MySQL accounts and limit access to phpMyAdmin at least with IP addresses.