Sometimes MySQL crash for various reasons (out of memory), there is a simple hack to make sure MySQL running.
Save this to dbcheck.sh
if [[ ! `$PIDOF -s mysqld` ]]; then
$SERVICE mysqld restart # can be mysql or mariadb
echo "DB restarted"
echo "DB is healthy"
Make it executable by chmod +x dbcheck.sh , and setup a cronjob as root for it to run periodically (e.g. every minute)
* * * * * /home/jason/dbcheck.sh > /dev/null
Note that this is not considered a good practice, you should find out what is crashing the DB/service, but it is a simple hack to save your some time.