Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
634 views
in Technique[技术] by (71.8m points)

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

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:

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.

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).

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Test

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

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

Fix

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

Resolution

Now MySQL should work normally

mysql -u root -p

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...