MySQL Socket Error 2002 on Mac – How to Fix

macMySQLsocket

A have already read everything about this error but I coundn't solve the problem.

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (38)

I'm trying to install mysql on my Mac OsX but when I try to connect to the db (mysql -u root -p) I see this problem, ERROR 2002.

I have Mysql installed in /usr/local/mysql

Best Answer

Check the MySQL daemon is running

You can check if the mysqld daemon from **Terminal Application* running:

ps -feax | grep mysqld 

And verifying that you get something similar to this:

    0  8308     1   0   0:00.08 ??         0:00.11 /bin/sh /usr/local/mysql/bin/mysqld_safe

or looking for a mysqld process on the Activity Monitor application

If it's not running you have to start the daemon.

Start MySQL daemon

On Mac OSX you can start the daemon from the Terminal Application with something like this:

sudo /usr/local/mysql/bin/mysqld_safe &

Again check that now the MySQL daemon is running as described before.