What is the "Error Establishing a Database Connection" error?
This error means that your Wordpress script either cannnot locate the database, or is being refused the ability to connect to the database.
What causes this error?
This error can occur due to a few different causes, each one is described along with recommended solution.
Incorrect connection parameters
By far the most common, having incorrect connection credentials will cause the error. These credentials are located in the wp-config.php file found in the root folder for your WordPress installation.
There are three credentials: database name, database user, and password.
Make sure these match the information located in your cPanel.
If you know the current database user password, you can reset it. If you do not know it, you will not be able to view the current password, so you will need to delete and then recreate the database user, giving it the password found in the wp-config.php file.
If this is the issue, then the problem should be solved and the site should display normally
Corrupted database tables
If you have confirmed the credentials are correct and still get the error, the issue could be caused by corrupted database tables.
Database tables can be checked and repaired from within the cPanel.