Question

Apache and MySQL crashing

  • Posted November 23, 2014

I have a problem about Apache and MySQL that are often crashes. I’ve read the same problems about this matter, and “ivan.denkov87” suggest something like this:

“I use a script to check couple of services every 5 minute if they are running, and start / restart them if they do not. You can use” monit “”

Anyone know or maybe have an example script? I want to try it.

thank you

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

Hello, @beitisetiawan

I will recommend you to examine the MySQL error_log as well, because this is likely to give you a more verbose error and point you in the right direction to see what exactly is causing the issue here.

The location of the error_log should be:

/var/log/mysqld.log or /var/log/mysql/error.log

If you’re unable to locate the error_log in this two locations you can double check your my.cnf file and see if the error_log is saved somewhere else.

What you can do is to examine the last logged entries in the log using tail

You can use either:

tail -f /var/log/mysqld.log and tail -f /var/log/mysql/error.log

or

tail -n 100 /var/log/mysqld.log and tail -n 100 /var/log/mysql/error.log

You can share the output of the log here so we can have a look.

You can also create a simple bash script to check if MySQL is running and if not to restart it.

#!/bin/bash

# Check if MySQL is running
sudo service mysql status > /dev/null 2>&1

# Restart the MySQL service if it's not running.
if [ $? != 0 ]; then
    sudo service mysql restart
fi

Run this script every 5 minutes using a cron job like this one:

 */5 * * * * /home/user/scripts/monitor.sh > /dev/null 2>&1

Hope that this helps! Regards, Alex

Thank you for your suggestion.

Right! MySQL is still crashes . MySQL would not restart yesterday and I have to restart my VPS manually using SSH .

I 've changed the login page according to your suggestion manually .

Hopefully… this can prevent MySQL crashes .

Is there another solution to avoid crashes MySQL ?

thank you

Thanks… I’ll try it :)