Can’t connect to local MySQL server through socket /tmp/mysql.sock os x- ERROR 2002 (HY000) os x
![]()
The other day suddenly MYSQL on my OS X web server stopped working.
I was getting this error:
ERROR 2002 (HY000) Can’t connect to local MySQL server through socket /tmp/mysql.sock
No matter what I did all I got was:
Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’
after a few hours of searching I finally found the answer. Something had overwriting my /tmp folder. The tmp folder in OS X should be a symbolic link to /private/tmp.
To find out if your tmp file is a symbolic link
![]()
Open a Terminal window (Applications -> Utilities - > Terminal)
Type:
ls -la / | grep tmp
You should get:
lrwxr-xr-x 1 root staff 12 Nov 24 23:46 tmp -> /private/tmp
In my case it was not, it was an actual folder. To correct this:
Open a Terminal window (Applications -> Utilities - > Terminal)
Type:
sudo mv /tmp /tmp.old
Then type:
sudo ln -s /private/tmp /tmp
Reboot and restart MYSQL.