我刚刚将我的 mac 更新到 10.13 并重新安装了我的开发工具。设置 phpmyadmin 时无法使用以下方式连接到 mysql:
$cfg['Servers'][$i]['host'] = 'localhost';
phpmyadmin 抛出:
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.
相反,我不得不使用它来让它工作:
$cfg['Servers'][$i]['host'] = '127.0.0.1';
在过去,我可以保留默认的“localhost”并且没有任何问题,但它不会再通过套接字连接。
我的mysql用户是'root'@'localhost',使用最新的mysql、apache、phpmyadmin。
可能是什么原因? 谢谢
最佳答案
感谢@N00b Pr0grammer 的建议,我尝试了不同的解决方案,但我还是想出了办法。
在全新安装的 OS X 中,php.ini 已关闭,默认情况下会在“/var/mysql/mysql.sock”中查找 mysqli.default_socket,因此我不得不 1. 重命名 php.ini。默认
为php.ini
2. 设置:
mysqli.default_socket = /tmp/mysql.sock
然后重启apache。现在 phpmyadmin 也可以通过本地主机连接到 mysql。
关于mysql - 为什么 phpmyadmin 拒绝通过本地主机连接但接受 127.0.0.1?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49839026/