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 am in a problem. I have accidentally deleted etc/mysql by writing sudo rm -r /etc/mysql .How can i restore it or if not then what to do next .when I am typing mysql command its saying :

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (13) what to do next ?

share|improve this question

migrated from Nov 1 '10 at 11:43

This question came from our site for professional and enthusiast programmers.

do you have a backup? /etc/mysql has "only" configuration files, right, not your database? – Thilo Nov 1 '10 at 5:38
that is about as non accidentally an issue I've ever seen. "I accidentally died when I pointed a gun at my head and pulled the trigger - how do I fix it?"... This is a natural selection. – Marm0t Nov 1 '10 at 6:04
up vote 2 down vote accepted

Go to your most recent backups and restore all the files. And. if you don't have a recent backup, why the blazes not?

Assuming you can get the information back using what will undoubtedly be some good answers here, institute a backup policy!. Disk space is ridiculously cheap.

Marked CW since it doesn't answer your specific problem but it is useful, mark my words. Anyone who reads this answer and doesn't back up their stuff in a timely manner, take heed, you will get burnt (and, if it's your digital photo collection of wife and kids from the last ten years, your wife will have every right to castrate you while you sleep).

If this happens to you again, you deserve all the angst you'll get and I will openly mock and deride you :-)

share|improve this answer
there are 2 types of admins: those who have lost data, and those who have not ... yet. But it is not funny when it happens to you. – natxo asenjo Nov 1 '10 at 12:33
Asshat, this has nothing to do with OP's question. Once /etc/mysql get deleted, all mysql-* packages install/remove will fail. – sdaffa23fdsf May 21 at 12:11
@sdaffa23fdsf, the fact that the OP accepted the answer appears to indicate otherwise. And you may want to check your facts - you appear to be saying that the deletion of a directory means you can never recover from that. I have to challenge that since, if you put everything back the way it was, it will work fine. – paxdiablo May 21 at 12:55

What about just reinstalling mysql then?

share|improve this answer
I have tried but not working..... – Subhransu Mishra Nov 1 '10 at 6:00
@yosanu: well - if you have reinstalled /etc - you have to get the fresh and ready to work mysql. – zerkms Nov 1 '10 at 6:02
@zerkms how to do that. – Subhransu Mishra Nov 1 '10 at 6:06
@yosanu: I'm sorry, but I think you need to learn linux basics? – zerkms Nov 1 '10 at 6:11
@zerkms KO fine.....bebye – Subhransu Mishra Nov 1 '10 at 6:13

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.