I have a digitalocean ubuntu vps for development use only, But sometimes the mysql server stop working. As per my investigation I don't have enough memory to handle few laravel installation. As I use the server only for development purpose so I don't want to upgrage the server. So for now I have to start the mysql when that stop working.

Is there anyway that will start mysql automatically once that stop working?

2 Answers 2


The tool that is generally used for this purpose is monit.

Digital Ocean has a tutorial about it, which also includes an example on how to keep MySQL running. The short synopsis is:

  1. Install monit

    sudo apt-get install monit
  2. Edit the configuration file:

    sudo nano /etc/monit/monitrc

    and include the following in it:

    check process mysqld with pidfile /var/run/mysqld/mysqld.pid
        start program = "/etc/init.d/mysql start"
        stop program = "/etc/init.d/mysql stop"
  3. Reload the new configuration:

    monit reload

I strongly suggest you look at the MySQL error log to understand why it is stopping (it should not do this in normal operation). It would be a good idea to also run mysqlrepair to check the status of all tables as you might have some serious DB corruption.


If mysql stops working you need to investigate why. There is no reason for it to behave this way. Make sure that you have enough memory and that you allocate swap.

Not the answer you're looking for? Browse other questions tagged .