mysqli_real_connect(): (HY000/2002): 没有那个文件或目录

2021-12-25 00:00:00 macos php mysqli phpmyadmin
mysqli_real_connect(): (HY000/2002): No such file or directory

MacOS 上的 PhpMyAdmin 错误.我想要答案我真的不知道我需要做什么来解决这个问题.

PhpMyAdmin error on MacOS. I want answer I really have no idea what I need to do to resolve this.

推荐答案

将/etc/phpmyadmin/config.inc.php 中的 localhost 更改为 127.0.0.1

change localhost to 127.0.0.1 in /etc/phpmyadmin/config.inc.php

$cfg['Servers'][$i]['host'] = '127.0.0.1';

这是因为如果你使用本地主机,pma 会尝试连接到 mysql.socket.如果你使用 127.0.0.1 PMA 建立一个应该可以工作的 TCP 连接.

The reason for this is that pma tries to connect to the mysql.socket if you use localhost. If you use 127.0.0.1 PMA makes a TCP connection which should work.

相关文章