Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When i'm trying to start MySQL server the following error occur:

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

Any ideas what this error means and how I can fix it?

share|improve this question
    
What OS are you attempting to run MySQL on? –  Kenny Sep 18 '11 at 18:10
    
Mac os x (lion) –  amg Sep 19 '11 at 7:49

2 Answers 2

This article may be of use.
Solve: Can’t connect to local MySQL server through socket /tmp/mysql.sock

Below is an a part of the article with the most important bit. (Read the whole article for the solution)


For the mysql client, the default location of this socket file is /tmp/mysql.sock. However, for a variety of reasons, many MySQL installations place this socket file somewhere else like /var/lib/mysql/mysql.sock.

share|improve this answer

OK, so the most likely explanation for this error is that you've not got the MySQL server running. Since you're running on a Mac, try this to start MySQL:

user@host:~$ cd /usr/local/mysql
user@host:~$ sudo ./bin/mysqld_safe &

After that last command, you might need to press your ENTER key one extra time to get the command prompt back to showing what you'd normally expect, but the MySQL server should now be started - look at the output and it'll hopefully say something like:

user@host:~$ 110923 20:13:23 mysqld_safe Logging to '/usr/local/mysql-5.1.53-osx10.6-x86_64/data/teaksaw.local.err'.
110923 20:13:23 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql-5.1.53-osx10.6-x86_64/data

Now, try logging in to mysql:

user@host:~$ mysql -u root

Hopefully, you're now cooking with gas.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.