ERROR 2002 MYSQL socket /tmp/mysql.sock
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
Solution 1:
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.
Solution 2:
You say you get the error when you run mysql -u root -p
This will look for a socket file to connect. When mysqld started up, it is possible for the socket file not to be made and still have mysqld start up ( See my post Percona-server time out on /etc/init.d/mysql start )
Try using one of the following to see if you can connect without a socket file
mysql -u root -p -h127.0.0.1
mysql -u root -p -h127.0.0.1 --protocol=tcp
If you can connect with one of these, the shutdown mysql like this
mysqladmin -u root -p -h127.0.0.1 --protocol=tcp shutdown
mysqld should shutdown properly. Afterwards, startup mysql as usual
Give it a Try !!!