Have you recently changed the password to the WordPress database? Or maybe you just have unexpected seen the “Error Establishing a Database Connection” error. It is rather dreadful because you cannot see your posts, and you can’t access the admin pages. You may have thought that you have lost all the posts that you have built up for years. Luckily it is generally not the case.
In general this database connection issue is caused by mismatched passwords. One of the reasons is that the change of password at cPanel somehow was not propagated to the actual WordPress database. So what you need is to make sure the two sets of passwords are the same.
There are two ways to change the WordPress database connection password – either go to PHPMyAdmin or change directly on the wp-config.php file. I feel more comfortable modifying the php file as I can see exactly what has been changed. This is how:
1. Connect to the WordPress hosting server.
2. In the installation folder, find the file named wp-config.php
3. Download a copy to your local hard drive and open it. The first line should be “<?php”
4. Scroll down until you see “/** MYSQL database password */”
5. Replace “Your Password” with your own one under “define (‘DB_PASSWORD’, ‘[Your Password]‘);” (REMEMBER to keep the quotation marks)
6. Mark sure this password is the same as the one you changed on cPanel if it applies.
You can also find more information here.