设置phpmyadmin链接多个数据库 - tianjiewang的专栏 - CSDN博客

[](http://creativecommons.org/licenses/by-sa/4.0/)版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

本文链接:https://blog.csdn.net/tianjiewang/article/details/51910546

安装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下

参考


Original url: Access
Created at: 2019-09-18 19:54:23
Category: default
Tags: none

请先后发表评论
  • 最新评论
  • 总共0条评论