Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to specify host when login in phpMyAdmin?

I am wondering if it is possible to specify host on the login screen of phpMyAdmin.

Whenever I need to connect to different server, I have to edit the host field in config.inc.php.

like image 255
Charandeep Singh Avatar asked May 03 '12 17:05

Charandeep Singh


1 Answers

Take a look at this:

http://www.onlinehowto.net/config-multiple-servers-in-phpmyadmin/1405

/* Single server config section */
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'dbsub';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = 'mysql';

Above six lines of code configure PhpMyAdmin to connect to one server. Notice the i > variable that gets increased on the fist line $i++. To define another server just you need to copy paste the block above and change the hostname. It is very important to have the $i++ statement before each databases server configuration. The servers could also be from different database type. For example MySQL and PostgreSQL. This is why PhpMyAdmin is so popular and loved.

Here is working setup in one of the phpmyadmin instances that we manage

/*
* Servers configuration
*/
$i = 0;

/*
* First server
*/
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'db';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = 'mysql';
/*
* Second server
*/
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'dbsub';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = 'mysql';
/*
* Third server
*/
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'stats1';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = 'mysql';

$cfg['DisplayServersList']    = TRUE;

/*
* End of servers configuration

The final change that will make the list of servers show in a nice dropdown list in the login scree is the $cfg[''DisplayServersList''] = TRUE; statement. This way any time you go to the login page of phpmyadmin you will have to select the server you want to work on.

like image 54
milenmk Avatar answered Oct 26 '22 14:10

milenmk