PhpMyAdmin is installed by default and can only be connected to one MySql server. Its configuration information is stored in the phpMyAdmin configuration file. When we need to switch between multiple servers for login, it is very troublesome to modify. According to the following configuration method, we can easily use phpMyAdmin to connect multiple MySQL instances.
Method 1: Enter the Server IP address, user name, and password when logging on to phpMyAdmin.
Disadvantage: the login operation is cumbersome, and you must first log out of the currently logged-on server when switching the server
Operation Procedure: Modify/libraries/config. default. php under the phpMyAdmin directory
/**
* Allow login to any user entered server in cookie based authentication
*
* @ Global boolean $ cfg ['allowarbitraryserver']
*/
$ Cfg ['allowarbitraryserver'] = true;
Change the default value false to true;
To avoid losses caused by incorrect modification, we strongly recommend that you back up the config. default. php file to config. default. php. bak.
Method 2: When logging on to phpMyAdmin, you only need to enter the user name and password. The server address is optional in the drop-down list. After logging on to phpMyAdmin, you can also select another server to switch quickly. (Recommended)
Advantage: it is easy to log on. After login, you do not need to exit the current connection after switching the server.
Procedure:
1. Back up the config. sample. inc. php file under the phpMyAdmin root directory to config. sample. inc. php. bak (this operation avoids losses caused by mismodification)
2. Back up the config. inc. php file in the phpMyAdmin root directory to config. inc. php. bak (this operation avoids losses caused by mismodification)
3. Rename the config. sample. inc. php file under the phpMyAdmin root directory to config. inc. php.
4. Modify the config. inc. php file, locate the First server comment section, and change it to the following content:
$ Hosts = array (
'1' => array ('host' => 'localhost', 'user' => 'root', 'Password' => '123 '),
'2' => array ('host' => '192. 168.0.1 ', 'user' => 'ciray', 'Password' => '2016 ')
);
// $ Hosts array subscript starts from 1, the host value is the Server IP address, the user is the corresponding MySql login user name, the password value is the MySql login password, please change to your own
// $ Two servers are configured in the hosts array. If you have multiple servers, add the configuration information in ascending order according to the array subscript.
/*
* First server
*/
For ($ I = 1; $ I <= count ($ hosts); $ I ++ ){
/* Authentication type */
$ Cfg ['servers'] [$ I] ['auth _ type'] = 'cooker ';
/* Server parameters */
$ Cfg ['servers'] [$ I] ['host'] = $ hosts [$ I] ['host']; // modify the host
$ Cfg ['servers'] [$ I] ['connect _ type'] = 'tcp ';
$ Cfg ['servers'] [$ I] ['compus'] = false;
/* Select mysqli if your server has it */
$ Cfg ['servers'] [$ I] ['extension'] = 'mysql ';
$ Cfg ['servers'] [$ I] ['allownopassword'] = true;
$ Cfg ['servers'] [$ I] ['user'] = $ hosts [$ I] ['user']; // modify the user name
$ Cfg ['servers'] [$ I] ['Password'] = $ hosts [$ I] ['Password']; // password
/* Rajk-for blobstreaming */
$ Cfg ['servers'] [$ I] ['bs _ garbage_threshold '] = 50;
$ Cfg ['servers'] [$ I] ['bs _ repository_threshold '] = '32m ';
$ Cfg ['servers'] [$ I] ['bs _ temp_blob_timeout'] = 600;
$ Cfg ['servers'] [$ I] ['bs _ temp_log_threshold '] = '32m ';
}
Please note that we use a for loop to configure the information of all servers. The initial value of the loop variable $ I is 1, and the configuration information in the $ hosts array is traversed. The content in the loop body does not need to be changed.
After modification, save the file and log on again. If the phpMyAdmin logon page displays a list of server candidates, the modification is correct.
If you accidentally modify the file, you can restore the file backed up in step 1 and 2.
[Note] method 1 and method 2 cannot be mixed. If method 1 is used, method 2 cannot take effect.