I have an Ubuntu 14.04 instance running the LAMP stack. Everything was working fine. Yesterday all of a sudden, the server started denying access to login via root. After a couple of trials, I gained access to the system. To my realisation, dpkg directory had some issues which I fixed by manually making folders. Still the application did not start. Upon further investigation, I noticed that

MySQL - Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

was being displayed on the application home page. Going further, I found out that the entire MySQL data along with the logs had disappeared. I don't know what is wrong!! Kindly help with solutions.

  • 3
    Your MySQL data lives in /var/lib/mysql, not in /var/run/, if that helps. – Jos Mar 27 at 9:47
  • I had around 100 tables which is nowhere to be found in /var/lib/mysql. /var/run contained the socket related issue. – Hitesh Suvarna Mar 27 at 10:12
  • MySQL files are writable only by the mysql user. So if they have been deleted, it must have been by a root-level process. Stop the MySQL server, restore your data from backup, and restart the server. – Jos Mar 27 at 10:16
  • In the /var/lib/mysql folder, I can see ibdata1, ib_logfile0, ib_logfile1. How do I use that to recover data? Also do you know what is the cause of such issues? – Hitesh Suvarna Mar 27 at 10:22
  • 1
    Those are your data files. The tables are inside them, unless you have somehow reinitialized the server. Restart the server and do show databases etc. – Jos Mar 27 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.