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