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!

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

1 Answer

up vote 4 down vote accepted

install and use monit

http://mmonit.com/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/mysqld.pid
   group database
   start program = "service mysql start"
   stop program = "service mysql stop"
   if failed host 127.0.0.1 port 3306 protocol mysql then restart
   if 5 restarts within 5 cycles then timeout
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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