2
votes

I am getting the following error

error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'

How can i restore the mysql.sock file?

[Edit]

I am trying to connect to mysql database from my ROR application. It was working fine till yesterday. But today I found out the mysql.sock file was missing. I don't know the reason of what led to deletion of mysql.sock file from location /var/lib/mysql/. How can i restore the mysql.file?

Thanks.....

3
You really need to show what you have been doing. You can't expect any help without more information. - Max Kielland
I am sorry.... have updated the question... - Anubhaw
Are you positive your MySQL server is up and running? - raidfive
You could add further information such as your operating system and how you installed MySQL - Ryan Bigg

3 Answers

6
votes

Try this:

$ mysql_config |grep -- --socket

It should show you the socket path as compiled in to the server. If that fails, try running the mysql command and look for the socket path in the output of \s.

1
votes

here is a rude yet quick way to solve this, but if your data or operation is important, you'd better find an other way

  1. kill all the mysql process

  2. now your mysql should be stopped, but locked.

    So delete the lock file and restart mysqld

    rm /var/lock/subsys/mysqld

    /etc/init.d/mysqld start

0
votes

I had the same problem and after spending some time i got the solution. From your terminal run this command -- sudo apt-get install mysql-server