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

Asked by Kayode Odusote

For reasons I cannot explain, MySQL server connection is lost both at the terminal and through phpMyAdmin. I have tried all solutions to similar problems on the web and none has worked. I am unable to stop the server from running with /etc/init.d/mysql stop or service mysql stop. I am denied access to /var/lib/mysql. It has not allowed me to upgrade the server either. I could not use killall mysql as I do not know the syntax. I am working on an application that is developed with MySQL as the database. Now I am stuck and have no clue as to what next except uninstall Ubuntu and start all over again. NOT an interesting thought.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu mysql-dfsg-5.1 Edit question
Assignee:
No assignee Edit question
Solved by:
Kayode Odusote
Solved:
Last query:
Last reply:
Revision history for this message
Kayode Odusote (odusote-kayode) said :
#1

I finally solved it.

The error in my case was due to corrupted database that was caused by a force shutdown when the system hung.

The only way it was solved was as follows:

    sudo apt-get purge mysql-server-5.1
    sudo mv /var/lib/mysql /var/lib/mysql.corrupted
    sudo apt-get install mysql-server-5.1

Everything is working fine now - no error but old database lost.

Lesson: Backup your database regularly just in case the unexpected happens.