无法通过套接字自制程序连接到本地MySQL服务器
我最近尝试使用自制软件(brew install mysql
)安装MySQL,当我尝试运行它时,出现以下错误:
I recently tried installing MySQL with homebrew (brew install mysql
) and when I try to run it I get the following error:
ERROR 2002(HY000):无法通过套接字'/tmp/mysql.sock'(2)连接到本地MySQL服务器
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
既没有/tmp/mysql.sock
也没有/var/lib/mysql.sock
.
我已经搜索并且没有找到任何mysql.sock
文件.
I've searched and haven't found any mysql.sock
file.
我该如何解决?
通过以下方式运行服务器
When you got the server running via
mysql.server start
您应该在/tmp/mysql.sock 中看到该套接字.但是,系统似乎期望它在/var/mysql/mysql.sock 中.要解决此问题,您必须在/var/mysql 中创建符号链接:
you should see the socket in /tmp/mysql.sock. However, the system seems to expect it in /var/mysql/mysql.sock. To fix this, you have to create a symlink in /var/mysql:
sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
这为我解决了.现在,我的phpMyAdmin可以与 localhost 和 127.0.0.1 一起愉快地工作.
This solved it for me. Now my phpMyAdmin works happily with localhost and 127.0.0.1.
信用转到> Henry