MySQL drops out every few days?

Posted September 26, 2012 14.4k views
So I have followed the tutorial to Install Wordpress, Nginx, PHP, and Varnish on Ubuntu 12.04. The process was smooth and easily installed, so no problems there. The issue is every few days the MySQL connect drops out and when I run the command: $ sudo service mysql start I get a the following message: $ start: Job failed to start The other issues is when it first happened, I looked into setting up a script to run in cron every 5 minutes. # CHECK DATABASE STATUS # ps auxw | grep mysql | grep -v grep > /dev/null if [ $? != 0 ] then sudo service mysql start > /dev/null fi Then added this to $ cron -e */5 * * * * ~/ But that is not working either, any thoughts or help would be greatly appreciated.
  • I am getting the same problem! My Server Mysql stop working few times a day

  • same here :) fails after a few days providing the “Error establishing a database connection”

  • @talaviram MySQL is most likely crashing because it’s running out of memory. You can add swap to your droplet which should help with that:

    If MySQL still crashes with a swapfile, you might have to upgrade your droplet to a plan with more RAM.

    by Justin Ellingwood
    Swap space can be used as an "overflow" area for your system when you run out of RAM. The operating system can store data that would normally be kept in RAM on the hard drive in a specially formatted file. In this guide, we'll demonstrate how to create and use one of these files in Ubuntu 14.04.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
10 answers
Try to start it again and then check your logs:

tail /var/log/mysql.err
tail /var/log/mysql.log
dmesg | grep mysql

It should say what's wrong, and why it's not starting :)
Your virtual server is most likely running out of resources you can resize to a larger server or add swap.

We added articles on how to add swap to the community section.
I have the same problem, i tryied to resize the VPS from 500mb to 1000mb, but MySQL refuses to start...
Sorry for the late reply. It seems to be working after a hard reboot.

Silvio - Thanks for the advice but unfortunately the logs where empty.

Raiyu - The Community section REALLY needs a Search function, it becomes to time consuming to navigate and find answers. Can you please provide the link to the add swap article?
Here are the links to the articles on how to add Swap in both Ubuntu and CentOS

Thanks for the suggestion on search for the community, it's already in the works along with auto-search for users when you open up a ticket which will display articles and forum entries which may have info on how to solve an issue.
by Etel Sverdlov
Linux swaps allow a system to harness more memory than was originally physically available. Here's how to set up a linux swap file on Ubuntu 12.04
Thanks :) And good to know that search is in the pipeline.
Setting up the swap fixed it for me.
I had same problem, setting up the swap fixed it for me.