SSH into your server.
Create this file:
mysql_ping.sh:
#!/bin/bash
#Checking whether MySQL is alive or not
if mysqladmin ping | grep -q "alive"; then
echo "OK"
else
service start mysql
fi
Then, do the following:
sudo -s
chown root mysql_ping.sh
chmod +x mysql_ping.sh
mv mysql_ping.sh /usr/sbin
crontab -e
In crontab, set that to run every second:
* * * * * * /usr/sbin/mysql_ping.sh > /dev/null 2>&1
save, exit, and exit out of the root user account. you can also log out of the server at this point as well.
This should live in root's crontab entry, so that it is actually able to start/stop the service. Not gonna be much help if it's sitting there waiting on someone to enter a sudo password.. ;)
So. What this will all accomplish is, every second the mysql server will be pinged, if it's alive nothing happens, if it does not respond, the service will be started.