Anubhaw
Anubhaw

Reputation: 6068

Can't connect to local MySQL server through socket

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.....

Upvotes: 2

Views: 3472

Answers (3)

Addicted
Addicted

Reputation: 749

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

Upvotes: 0

taijirobot
taijirobot

Reputation: 141

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

Upvotes: 1

noodl
noodl

Reputation: 17408

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.

Upvotes: 6

Related Questions