设置phpmyadmin链接多个数据库

安装phpmyadmin

# 官网地址:https://www.phpmyadmin.net/
# 安装phpmyadmin,不用使用apt-get安装,直接用源包解压
wget https://files.phpmyadmin.net/phpMyAdmin/4.6.6/phpMyAdmin-4.6.6-all-languages.zip
unzip phpMyAdmin-4.6.6-all-languages.zip
sudo cp -R -p phpMyAdmin-4.6.6-all-languages /usr/share/phpmyadmin

# apt-get安装
sudo apt-get install phpmyadmin

查看phpmyadmin安装目录

$ whereis phpmyadmin
phpmyadmin: /etc/phpmyadmin /usr/share/phpmyadmin

方法一

  • 修改/usr/share/phpmyadmin/libraries/config.default.php
/** 
 * allow login to any user entered server in cookie based authentication 
 * 
 * @global boolean $cfg['AllowArbitraryServer'] 
 */  
$cfg['AllowArbitraryServer'] = true; //默认是false,改成true 

方法二

  • 复制/usr/share/phpmyadmin/config.sample.inc.php,命名为config.inc.php
 $ cd /usr/share/phpmyadmin
 $ sudo cp config.sample.inc.php config.inc.php
  • 修改config.inc.php文件,在第一个Servers配置下加多一个数据库配置
$i++;
$cfg['Servers'][$i]['verbose'] = 'tlwlmy';    // 链接名字
$cfg['Servers'][$i]['host'] = '192.168.0.1';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

方法三

  • 修改/etc/phpmyadmin/config.inc.php,在第一个Servers配置下加多一个数据库配置
$i++;
$cfg['Servers'][$i]['verbose'] = 'tlwlmy';    // 链接名字
$cfg['Servers'][$i]['host'] = '192.168.0.1';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

总结

  • 使用第一种方法,需要自己填写host,切换数据库比较麻烦
  • 第二种方法要使用官网下载安装包
  • 第三种方法要使用apt-get安装,使用apt-get文件会在/etc/phpmyadmin下

参考

  • http://blog.51yip.com/mysql/1250.html(方法一和方法二)
  • http://www.onlinehowto.net/config-multiple-servers-in-phpmyadmin/1405(方法二)
  • http://www.linuxfunda.com/2013/10/06/how-to-manage-multiple-mysql-server-using-one-phpmyadmin/(方法三)

你可能感兴趣的:(mysql,服务器)