Linux版本於內核號 CentOS release 6.5 (Final) 2.6.32-431.el6.x86_64 PHP版本 5.3.28 Phpmyadmin版本 phpMyAdmin-4.4.15-all-languages MySQL多實例 192.168.0.200:3307和192.168.0.200:3308(其中3307爲master 3308爲slave)
經過修改 phpmyadmin/libraries/config.default.php
大概在805行的$cfg['AllowArbitraryServer'] = true;
# allow login to any user entered server in cookie based authentication,效果以下圖:
進行登陸,固然這種方式依然得方法一中第四步的受權,這裏就不在贅述。(此方法測試未成功,繼續關注)php
缺點:登錄操做比較繁瑣,並且切換服務器時須首先退出當前所登錄的服務器mysql
到https://www.phpmyadmin.net/downloads/
下載phpMyAdmin-4.4.15-all-languages
,解壓到網站根目錄下重命名爲phpmyadminsql
cp config.sample.inc.php config.inc.php
複製根目錄下的config.sample.inc.php
爲config.inc.php
,使用 sed -i '22,34s#^#//#g'
config.inc.php使用sed命令註釋掉以前相關行並編輯這個文件,添加一個$hosts數組和一個for循環,以下:數據庫
// /* // * First server // */ // $i++; // /* Authentication type */ // $cfg['Servers'][$i]['auth_type'] = 'cookie'; // /* Server parameters */ // $cfg['Servers'][$i]['host'] = 'localhost'; // $cfg['Servers'][$i]['connect_type'] = 'tcp'; // $cfg['Servers'][$i]['compress'] = false; // /* Select mysql if your server does not have mysqli */ // $cfg['Servers'][$i]['extension'] = 'mysqli'; // $cfg['Servers'][$i]['AllowNoPassword'] = false; $hosts = array( '1'=>array('host'=>'192.168.0.200','user'=>'phpmyadmin','password'=>'phpmyadmin','port'=>3307), '2'=>array('host'=>'192.168.0.200','user'=>'phpmyadmin','password'=>'phpmyadmin','port'=>3308) ); for($i=1,$j=count($hosts);$i<=$j;$i++){ /* Authentication type */ $cfg['Servers'][$i]['auth_type'] = 'cookie'; /* Server parameters */ $cfg['Servers'][$i]['host'] = $hosts[$i]['host']; //修改host $cfg['Servers'][$i]['port'] = $hosts[$i]['port']; $cfg['Servers'][$i]['connect_type'] = 'tcp'; $cfg['Servers'][$i]['compress'] = false; /* Select mysqli if your server has it */ $cfg['Servers'][$i]['extension'] = 'mysqli'; $cfg['Servers'][$i]['AllowNoPassword'] = true; $cfg['Servers'][$i]['user'] = $hosts[$i]['user']; //修改用戶名 $cfg['Servers'][$i]['password'] = $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'; }
更改完成後刷新登陸頁面,發現是否是多了些什麼?咱們能夠選擇不一樣的服務器(或者不一樣的端口)進行登陸了。以下圖:
數組
因爲這邊192.168.0.200:3307爲master,咱們在3307端口上進行受權: grant all privileges on *.* to 'phpmyadmin'@'192.168.0.%' identified by 'phpmyadmin' WITH GRANT OPTION;
若是3307和3308已經實現了主從同步,那麼咱們能夠經過用戶名爲phpmyadmin和密碼爲 phpmyadmin登陸了,可是這樣受權是十分不安全的。建議在生產環境中不要這麼粗暴的使用,另外咱們須要對slave實例進行回收權限,登陸192.168.0.3308,操做以下: REVOKE INSERT,ALTER,CREATE,DELETE,DROP,UPDATE ON *.* FROM 'phpmyadmin'@'192.168.0.%'
安全
另能夠經過show privileges;查看更多受權權限以及相關做用。
效果以下:
相關的增刪改操做提示無權限,防止用戶誤操做引發的主從同步數據的不一致。(這裏也能夠配置mysql庫的主從不一樣步,而後分別在3307和3308端口上授予用戶不一樣的權限便可)。服務器
優勢:登錄操做簡便,登錄後切換服務器無須退出當前鏈接。cookie