1、在phpmyadmin跟目录下面,找到config.sample.inc.php修改成为config.inc.php
找到如下这段代码,注释掉就可以了的。
//$i = 0;
/**
• First server
*/
//$i++;
/* Authentication type */
//$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
//$cfg['Servers'][$i]['host'] = '172.17.0.3';
//$cfg['Servers'][$i]['compress'] = false;
//$cfg['Servers'][$i]['AllowNoPassword'] = false;
替换为下面:
/*** Servers configuration*/
$server_hosts = array('1' => array('server_name' => 'mysql8', 'host' => '172.17.0.2', 'user'=>'', 'password' => '','port'=>3306),'2' => array('server_name' => 'mysql57', 'host' => '172.17.0.1', 'user'=>'', 'password' => '','port'=>3307));
foreach ($server_hosts as $key => $sh) {
$cfg['Servers'][$key]['verbose'] = $sh['server_name'];
$cfg['Servers'][$key]['auth_type'] = 'cookie';
$cfg['Servers'][$key]['host'] = $sh['host'];
$cfg['Servers'][$key]['port'] = $sh['port'];
$cfg['Servers'][$key]['user'] = $sh['user'];
$cfg['Servers'][$key]['password'] = $sh['password'];
$cfg['Servers'][$key]['connect_type'] = 'tcp';
$cfg['Servers'][$key]['compress'] = false;
$cfg['Servers'][$key]['extension'] = 'mysqli';
$cfg['Servers'][$key]['AllowNoPassword'] = false;
}
本人遇到的问题是:
mysql8是在docker容器运行。mysql5.7.40是在宿主机运行。
php也是在容器运行。php连接mysql8容器正常连接。用容器的IP进行访问即可。mysql5.7.40在宿主机,需要php容器访问宿主机的mysql,这个就涉及到docker0的网卡通信问题。这里直接填写docker0网卡IP即可访问(默认是172.17.0.1)
标签:phpmyadmin,cfg,配置,Servers,host,sh,key,mysql,server From: https://blog.51cto.com/wyf1226/5982194