Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am facing this error:

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

I tried every thing I found on Internet, but can not solve the problem. I am using Ubuntu 11.04.

I installed it with:

sudo apt-get install mysql-server
share|improve this question

3 Answers 3

That means it is not running. Do:

ps -ef | grep sql. 

You should see something like:

root      2266     1  0 14:32 pts/0    00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --user=mysql
mysql     2317  2266  1 14:32 pts/0    00:00:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --socket=/var/lib/mysql/mysql.sock
root      2338  2004  0 14:32 pts/0    00:00:00 grep sql

Since you are using Ubuntu, enable it and it start it up using upstart:

http://upstart.ubuntu.com/

share|improve this answer
    
I think it is configure i can use commands sudo start mysql and sudo stop mysql. But the error is still there. you can check more details of the question on stackoverflow.com/q/6525917/534329 –  Nazar Hussain Jun 29 '11 at 19:37

When I install MySQL on Ubuntu (11.04 and 12.04) I run this:

sudo aptitude install mysql-server mysql-client

Then I secure the install by running this script which would have been installed with the previous items:

sudo mysql_secure_installation

If somehow MySQL is not running, then force it to start by running this:

sudo service mysql start
share|improve this answer

Check the permissions of /var/run/mysqld/ - could be that the process cannot modify or create the socket.

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.