-
-
Save bnovoa/aa41f31b4db3a22812f752f46da260e0 to your computer and use it in GitHub Desktop.
MAMP: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I instaled MAMP and it worked great. However, when I tried to access mysql from the shell I was getting | |
$ mysql -u root -p | |
Enter password: | |
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) | |
However, using a full path to MAMP binary worked. | |
$ /Applications/MAMP/Library/bin/mysql -u root -p | |
MAMP’s mysql works with another socket file which is located at /Applications/MAMP/tmp/mysql/mysql.sock | |
All you have to do is: | |
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock | |
UPDATE: As it turns out the above soft link gets erased by the system, so you need to run the command every once in a while. At one point it got too frustrating so I figured out a permanent way to take care of this problem. Open /etc/my.cnf and add/edit these lines: | |
[mysqld] | |
socket=/Applications/MAMP/tmp/mysql/mysql.sock | |
[client] | |
socket=/Applications/MAMP/tmp/mysql/mysql.sock | |
Instead of telling MAMP which socket file to use, you are instructing the mysql client to use MAMP’s default socket. | |
Let me know if this works for you. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment