链接多个数据库的方法
把下面的代碼 寫到?phpmyadmin的文件里的config.inc.php 文件某處(見下面有說那里)
$connect_hosts = array(
'1'=>array(
"host" => "localhost", //本地服務器
"user" => "root",
"password" => ""
),
'2' => array(
"host" => "服務器IP", //服務器1
"user" => "username",
"password" => "pwd"
),
'3' => array(
"host" => "服務器ip", //服務器2
"user" => "username",
"password" => "pwd"
)
);
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']; //修改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']; //修改用戶名
$cfg['Servers'][$i]['password'] = $connect_hosts[$i]['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';
}
替換位置
這里需要注意:? (下面這個不用管也行)
(1)for循環的時候,i要從1開始,不要從0開始(2)配置文件中有個′i = 0’,記得注釋掉。也就是注釋掉無關的代碼
?
?后記:
找到phpmyadmin文件夾下面的config.sample.inc.php,重命名為config.inc.php 直接在這個文件下面加上,多個數據庫的代碼,然后覆蓋回原來的config.inc.php ,重啟服務,即可
?
參考:?https://blog.csdn.net/ljfphp/article/details/78717355
轉載于:https://www.cnblogs.com/kaibindirver/p/10446831.html
總結
以上是生活随笔為你收集整理的链接多个数据库的方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: UVA572
- 下一篇: CentOS 7下用firewall-c