HOW TO: fix the “Error Establishing a Database Connection” in WordPress
Posted by Sugen S. on 06 September 2018 01:26 PM
As a dynamic content management system, WordPress relies on a MySQL database that stores your content, website settings and more. If WordPress is unable to communicate with its database, you’ll see an error message stating: Error establishing a database connection.
If your WordPress website was previously working normally, clearly something has changed to break the link between WordPress and the database. Possible causes could be:
If this is the first time you’ve tried to use WordPress, the most likely cause is that your database credentials are incorrect or have changed. Use the following steps to troubleshoot the issue.
Check your WordPress configuration
When installing WordPress, you will have been asked to input a database hostname, database name, database username and password. These credentials are stored in your wp-config.php file. A great first step for troubleshooting database connection errors is to check that the database credentials in your wp-config.php file are correct.
You can use an FTP client to access the file on your hosting, or alternatively, use cPanel File Manager.
- Log in to your cPanel.
- Now select File Manager.
- Navigate to your WordPress folder and look for your wp-config.php file. Right click on the file and select Edit.
You’ll see your database credentials listed under MySQL settings. Check that the database hostname, database name, database usernameand password are correct. You can find your database credentials at My cPanel > MySQL Databases.
Make any necessary changes in your wp-config.php file and then click Save Changes to proceed. Try to access WordPress once again to see if your issue remains.