Sunday, April 26, 2009

Problems with mysql.sock

Sometimes while working on Linux, mysql.sock may get deleted by mistake due to some softwares.. in such cases any access to mysql wont be possible as the sock file defines the socket connection for mysql. It will give an error of the following type:

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

In such cases follow these steps to reconfigure mysql:

  1. Delete the log files with the names: ib_logfile0, ib_logfile1 and ibdata1 in the /var/lib/mysql directory
  2. Then type: "mysqld_safe --user=mysql &"
    This will automatically create mysql.sock file and even the new logs files.
This is a very simple solution which I used recently and decided to share with you people.