If you have WordPress sites on a VPS with less than 700mb-1gb of RAM, you may experience intermittent MySQL downtime as the service turns itself off when it exceeds your server or allocated resource usage.
The following commands will append to your crontab. This will check if mariadb/mysqld is running, if it’s not running, it will restart it.
If you have MySQL:
echo " * * * * * root /sbin/service mysqld status || service mysqld restart" >> /etc/crontab
If you have MariaDB:
echo " * * * * * root /sbin/service mariadb status || service mariadb restart" >> /etc/crontab
Verify it’s been added with: