Home  >  Article  >  Backend Development  >  Use phpmyadimn to connect and manage multiple databases_PHP tutorial

Use phpmyadimn to connect and manage multiple databases_PHP tutorial

WBOY
WBOYOriginal
2016-07-12 09:06:061027browse

Use phpmyadimn to connect and manage multiple databases

Using phpmyadimn to connect and manage multiple databases requires modifying configuration files, which is quite unpleasant, and the speed of connecting to remote databases is not good. Other database management tools can be used,
Please refer to navicat combined with shortcut keys. It is very easy to use, open source, and easy to use the mysql management tool HeidiSQL. If you must use phpmyadmin, there are two methods below to connect and manage multiple mysql servers.
Method 1, modify phpMyAdmin/libraries/config.default.php
Before modifying the configuration file, it is best to back it up. If you change the wrong place and it cannot be displayed, you will be depressed.
/**
 * allow login to any user entered server in cookie based authentication
 *
 * @global boolean $cfg['AllowArbitraryServer']
 */
$cfg['AllowArbitraryServer'] = true; //The default is false, change it to true
Before the modification, the server input box did not exist. After it becomes true, it will be displayed, and you can connect to multiple different databases. But there is a disadvantage in this modification,
If you switch between multiple databases, you have to log out first and log in again. This is quite annoying. See the method below.
Method 2, manage multiple mysql servers at the same time.
1. Rename config.sample.inc.php in the root directory of phpMyAdmin to config.inc.php
2. Modify the config.inc.php file
/*
* First server
*/
//If you want to manage more mysql servers, just modify the $connect_hosts array
$connect_hosts = array(
'1'=>array(
"host" => "localhost", //Server 1
"user" => "root",
"password" => ""
          ),
'2' => array(
"host" => "192.168.0.11", //Server 2
"user" => "wordpress",
"password" => "********"
        )
);
for ($i=1;$i<=count($connect_hosts);$i ) {
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = $connect_hosts[$i]['host']; //Modify host
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Servers'][$i]['user'] = $connect_hosts[$i]['user']; //Modify user name
$cfg['Servers'][$i]['password'] = $connect_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 the array subscript should not start from 0, otherwise an incorrect and invalid server index will be prompted: "0"
Before logging in,
phpmyadmin modify config.inc.php multi-server login
After logging in,
phpmyadmin connects to multiple mysql servers, after logging in
One thing to note is that after logging in with localhost, you will be asked to log in after selecting 192.168.0.11 in the drop-down menu above. After logging in, do not log in again when switching between multiple servers.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1065965.htmlTechArticleUsing phpmyadimn to connect and manage multiple databases. Using phpmyadimn to connect and manage multiple databases requires modifying the configuration file, which is quite unpleasant. , and connecting to the remote database, the speed is not good. Can be used...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn