SOLVED: Error establishing a database connection WordPress

For anyone who is getting “Error establishing a database connection” the solution is very simple . If you know how to use a FTP client like Filezilla you can login in and check to see if the wp-config.php file exists (see Figure 1). Your server/hosting panel might also have a file browser editor you can use to check. This file will be in the root directory where your WordPress is installed in.

SOLVED: Error establishing a database connection WordPress
WordPress root directory in FileZilla – Figure 1 

Solution: 
If this is a new WordPress installation use the file wp-config-sample.php and add your database username and password credentials and save the file as wp-config.php.

If the file is there and you have already added your database credentials find the line:

define( ‘WP_DEBUG’, false); and change false to true then re-save it.

This will give you a more specific error telling you either your username or password is wrong or it can’t connect to the database host. This will determine the next steps that need to be taken.