MySQL fails to start
2012-09-19
I recently ran into an issue where the MySQL database service would not start on my server. After searching around a bit (and being led astray a few times), I found the culprit: not enough RAM.
It turns out that my set up (Ubuntu 12.04 with 256 MB RAM) did not have a enough memory to run a wordpress install and the MySQL database required for it. These specs are fairly common for VPS's like mine and this should help you realize what is going wrong.
If you get ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
when you run sudo mysql start
or start: Job failed to start
when you run sudo /etc/init.d/mysql start
then you should check the amount of RAM your machine/instance has available. You just might be running low.
As for solving this issue, you can try killing unneeded services. My instance had plymouthd running, a daemon for the Plymouth graphical boot that comes with Ubuntu. So, with a headless install, I did not need this and killed it. You can also temporarily kill services (like Apache) just to get your MySQL off the ground, but beware: you might run out of memory again soon.
Also, VPS's like mine are even more vulnerable to this because many do not have any swap space allotted. So once your RAM is exhausted, you're in trouble.