phpmyadmin4.0配置多服務(wù)器(多數(shù)據(jù)庫)管理
來源:
發(fā)布時(shí)間:2017/9/7
瀏覽次數(shù):1364
我司上的慧林主機(jī)系統(tǒng),因自帶phpmyadmin版本較低,換成Phpmyadmin4.0,需要修改相關(guān)配置以方便管理多臺服務(wù)器的mysql數(shù)據(jù)庫。
1.將phpmyadmin根目錄下的config.sample.inc.php文件備份,以便修改錯誤時(shí)恢復(fù)原樣;
2.將config.sample.inc.php改名為config.inc.php;
3.修改config.inc.php文件里相關(guān)內(nèi)容:
$hosts = array(
'1'=>array("host"=>"192.168.0.1","user"=>"root","password"=>"123456"),
'2'=>array("host"=>"192.168.0.2","user"=>"root","password"=>"567890")
);
for($i=1;$i<=count($hosts);$i++){
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['host'] = $hosts[$i]['host'];
$cfg['Servers'][$i]['user'] = $hosts[$i]['user']; //修改用戶名
$cfg['Servers'][$i]['password'] = $hosts[$i]['password']; //密碼
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
改后保存,打開phpmyadmin主頁面登錄,發(fā)現(xiàn)報(bào)錯:
原來,服務(wù)器上mysql 數(shù)據(jù)庫root賬戶默認(rèn)不支持遠(yuǎn)程連接,那么,還得配置mysql讓root賬戶支持遠(yuǎn)程連接。
打開mysql命令行窗口,執(zhí)行
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
flush privileges;
其中'%'就代表任意主機(jī),當(dāng)然,你也可以改成指定遠(yuǎn)程服務(wù)器IP,例如:
grant all privileges on *.* to 'root'@'192.168.10.168' identified by '123456' with grant option;
flush privileges;
修改好,查看root用戶情況,可以看到支持%了。