VestaCP: Error Establishing a database connection (Digital Ocean/VPS Fix)

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:

1
echo   "  *  *  *  *  * root /sbin/service mysqld status || service mysqld restart" >> /etc/crontab

If you have MariaDB:

1
echo   "  *  *  *  *  * root /sbin/service mariadb status || service mariadb restart" >> /etc/crontab

Verify it’s been added with:

1
cat /etc/crontab

Leave a Reply

Your email address will not be published. Required fields are marked *