Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 278
Brandon Beeler Avatar asked Jun 19 '12 17:06

Brandon Beeler


People also ask

What is the synonym of error?

Some common synonyms of error are blunder, lapse, mistake, and slip. While all these words mean "a departure from what is true, right, or proper," error suggests the existence of a standard or guide and a straying from the right course through failure to make effective use of this.

What does mean in error?

Definition of in error 1 : not correct : mistaken I believe your conclusion is in error. The judge was in error when she allowed the evidence to be admitted. 2 : in a way that is not correct My earlier statement was made in error.

What is opposite of error?

Antonyms. rightness correctness natural object overgarment better. incorrectness wrongness erroneousness.


4 Answers

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
like image 71
davidcondrey Avatar answered Sep 20 '22 04:09

davidcondrey


I know this is late, but if ever someone is searching this (as I was tonight, but I found the solution), here's what worked for me:

I opened MAMP and had to click "USE default Apache and MySQL ports". (80 and 3306 instead of 8888 and 8889). That seemed to fix the issue.

like image 23
Tur1ng Avatar answered Sep 20 '22 04:09

Tur1ng


Silly solution... But in my case, I didnt start the mysql server. So, look that also!

like image 41
ValRob Avatar answered Sep 21 '22 04:09

ValRob


Mysql server has not started.

mysqld stop
mysql.server start
like image 40
Prakhar Agarwal Avatar answered Sep 22 '22 04:09

Prakhar Agarwal