Fix the "Error Establishing a Database Connection" in WordPress
WordPress is a dynamic content management system that depends on a MySQL database to store information like your content and website settings. Error establishing a database connection will be displayed if WordPress is unable to connect to its database.
Error Establishing a Database Connection Message
If your WordPress website used to function normally, then something obviously changed to cause the connection between WordPress and the database to break. Possible reasons include:
- The database server is down.
- A change has been made to the database credentials (hostname, username or password) in your wp-config.php file.
If you’re trying to use WordPress for the first time, the most likely reason is that your database credentials are wrong or have changed. To fix the problem, take the next few actions.
Check your WordPress configuration
You must have entered a database hostname, database name, database username, and password when installing WordPress. 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.
To access the file on your hosting, you can either use cPanel File Manager or an FTP client.
Firstly, log in to your cPanel.
Secondly, select File Manager.
Then, Navigate to your WordPress folder and look for your wp-config.php file. Right click on the file and select Edit.
Your database credentials are listed in the MySQL settings section. Verify the accuracy of the database hostname, name, username, and password. Your database login information can be found under MySQL Databases in My cPanel.
Make any necessary changes in your wp-config.php file and then click Save Changes to proceed. To see if your problem persists, try logging into WordPress once more.