错误#2002无法通过套接字'/Applications/MAMP/tmp/mysql/mysql.sock'连接到本地MySQL服务器(2)

问题描述:

我正在运行MAMP.
直到昨天一直运转良好.到目前为止,我还找不到任何有帮助的东西.但这是我的问题:

I'm running MAMP.
It has been working fine up until yesterday. I haven't been able to find anything that helps so far. But here is my problem:

标题显示我收到以下错误:

As the title states I'm receiving the following error:

错误#2002 无法通过套接字连接到本地MySQL服务器 '/Applications/MAMP/tmp/mysql/mysql.sock'(2)"

error #2002 "Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2)"

我注意到,

当我搜索它时,这似乎是一个非常常见的错误.

which, I have noticed, seems to be a pretty common error when I search for it.

无论如何,当我CD到tmp/mysqlls -laxo时,除了./../目录外,唯一显示的是.dummy(我不知道那是什么,但我有一种预感这不是我的问题的根源).

Anyway, When I cd to tmp/mysql and ls -laxo the only thing that shows up besides the ./ and ../ directories is .dummy (I have no idea what that is, but I have a hunch it's not the source of my problem).

这是mysql.sock文件的假定位置.有谁知道解决此问题的方法.也许我需要创建mysql.sock文件,但是我不知道要放什么.

That is where the mysql.sock file is suppose to be located. Does anyone know of a way to fix this. Maybe I need to create the mysql.sock file but I wouldn't know what to put in it.

测试

如果您尝试使用完整路径启动MySQL,那么它应该可以工作

If you attempt to start MySQL using the full path it should work

/Applications/MAMP/Library/bin/mysql -u root -p


修复

如果可以,那么您可以通过运行将其设置为正常工作

If that works, then you can set it to work normally by running

sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock


解决方案

现在MySQL应该可以正常工作了

Now MySQL should work normally

mysql -u root -p