Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have very often downs mysql for some reason.

I would like to learn how to make a script that would check does not fall if mysql is down - start it again.

service mysql start

Sorry for bad english!

share|improve this question
How about finding out why MySQL is going down? look in /var/lib/mysql/*.err for details . – thinice Dec 7 '11 at 3:35

1 Answer 1

up vote 4 down vote accepted

install and use monit

You can monitor the mysql process and if it is down monit can restart it for you.. a sample config might look like

check process mysql with pidfile /var/run/mysqld/
   group database
   start program = "service mysql start"
   stop program = "service mysql stop"
   if failed host port 3306 protocol mysql then restart
   if 5 restarts within 5 cycles then timeout
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.