quifflet
By:
quifflet

MySQL service not starting

December 15, 2013 4.8k views
One of my droplets is reporting that it cannot connect to the MySQL server. I've tried rebooting the droplet a couple of times but it hasn't made any difference. If I try connecting to the database via SSH get the following error: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) The droplet is running LAMP on Ubuntu 12.04, and is running a single website (MediaWiki). It's been fine since I set it up a couple of months ago. I haven't made any changes to the MediaWiki codebase or to the MySQL database itself since I set it up (apart from adding content to the wiki), so I don't really understand why it's suddenly stopped working now. Any ideas where to start? Where should I be looking re: log files etc?
2 Answers
I had this exact same issue last week. I spent the entire day reinstalling MySql, restarting apache, checking the error logs, upgrading the droplet to a bigger one, posting questions here, contacting DO support and googling the error, but nothing helped.

I finally just created a snapshot of the droplet and started a new droplet form the snapshot image, then changed the DNS entry for the effected sites to the new droplet and everything worked again. I never did find out why it stopped but it hasn't been a problem since.

Try taking a snapshot of your droplet and creating a new droplet from that image. That won't tell you what happened but it may get you up and running more quickly.
Have you been updating the software packages on your droplet, regularly? If not, execute:
sudo apt-get update && sudo apt-get -y upgrade && sudo apt-get -y dist-upgrade && sudo apt-get -y autoremove
Have another answer? Share your knowledge.