On one of my WordPress sites on a Bitnami image on Lightsail, my MySql instance would fail often. This script restarts it when it goes down.
#!/bin/bash # Check if MySQL is running if sudo /opt/bitnami/ctlscript.sh status mysql != "mysql already runn ing";then echo -e "MySQL Service was down. Restarting now...\n" sudo /opt/bitnami/ctlscript.sh restart mysql else echo -e "MySQL Service is running already. Nothing to do her e.\n" fi
sudo crontab -e
* * * * /home/bitnami/mysqlmon.sh > /dev/null 2>&1