The most common cause of "error establishing a database connection" in WordPress is your server running out of memory. When the server runs out of memory, MySQL will crash. The best solution is to upgrade to a server with more memory.
In addition to increasing your server's memory, you may want to reduce your WordPress site's memory usage.
You can confirm that your server is running out of memory by looking for the message "Out of memory" in the log file /var/log/syslog.
Another cause of "error establishing a database connection" is a full disk. You should check your server's disk space. If it is full, then you should either upgrade to a larger size or carefully delete unnecessary files.
If you have verified that your server is not running out of memory or disk space, you may have incorrect database credentials in your WordPress app's wp-config.php file. You should confirm that the database information in that file is correct.
Alert: For Control Panel Help & Tutorials, click here: Panel Tutorials