Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have mistakenly deleted some of the dependent file for mysql when I am trying to use mysql command i am getting following error :

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

I have tried reinstalling mysql-server but it still not resolved .

What should I do to bring back everything to normal condition.

EDIT: The operating system is UBUNTU . the log file(var/log/mysql_logs) is of byte . Nothing is there.

Please check the screenshot in this question .

share|improve this question
Make sure MySQL is started, for starters. – ceejayoz Aug 27 '12 at 12:50
Did you kill old mysql process? – dave Aug 27 '12 at 12:54
Please append you log files so we can see the exact log message. We are not able to read coffee grounds :( – wojciechz Aug 27 '12 at 13:37

Did you check that /var/run/mysqld/mysqld.sock exists, is a socket and accessible by the relevant parties? e.g.

 srwxrwxrwx 1 mysql mysql 0 

Your client is trying to connect via /var/run/mysqld/mysqld.sock, but is this what the server is using? If you can get a network connection, try:

 show variables like '%SOCKET%'

to verify the path.

Check /etc/my.cnf, /etc/init.d/mysqld and /etc/sysconfig/mysql[d] to see if the socket path has been overridden.

share|improve this answer
There is no such file: etc/my.cnf – Subhransu Mishra Aug 27 '12 at 16:09
There is no such file: etc/my.cnf and also other are not available . Please check the screenshot AND mysqld.sock does not exist :( – Subhransu Mishra Aug 27 '12 at 16:12
Then backup your data and do an apt-get --reinstall mysql-server (this shouln't overwrite your data files - but just in case). – symcbean Aug 30 '12 at 8:51

If you've tried 'reinstalling', it may have not deleted completely. You haven't stated your OS, but I assume linux:

For RPM based:

rpm -e mysql mysql-server

You may also want to/have to delete all the data. I believe that is located at /var/lib/mysql

for deb/apt based:

apt-get --purge remove mysql-server

Again, data should be in /var/lib/mysql

This should be done especially if you've removed dependent files from the mysql installation.

Also, ensure that you've actually started the mysql process.

share|improve this answer

Your Answer


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.