Fixing "Error Establishing a Database Connection"
Fixing "Error Establishing a Database Connection" can be intimidating. This error suggests that your WordPress site is experiencing difficulties connecting to your database. In this extensive guide, we will provide you with solutions to make sure that your website is always up and running. This may be caused by one of the following reasons:
-
Incorrect Database Credentials
-
Corrupted Database
-
Deleted Database
This error must be fixed right away as it prevents your website from loading, thereby affecting website traffic, sales, etc.
This is one of the most common reasons why you have the “Error establishing a database connection” error message on your website. To fix this error, you should check and ensure the accuracy of your database credentials.
You can find your database information in your Account Manager and in the root folder of your WordPress site, accessible via FTP.
In this section, we will discuss:
- How to Find My Database Credentials in My Account Manager
- How to Find My Database Credentials Via FTP
- How to Fix the Database Connection Error
How to Find My Database Credentials in My Account Manager
WordPress Hosting Package
If you have WordPress hosting from us, then you can follow the instructions below to locate your database credentials in your Account Manager.
- Log in to https://www.web.com/my-account/login.
- On the left side of the page, click WordPress.
- If you have multiple WordPress packages, select the package you want to access, then click Manage.
- Under Configurations, click Database Manager.
- Take note of the Database Name, Hostname, and Username listed in the MySQL Database table.
Hosting Package that Uses WordPress
If you have WordPress installed in your hosting package, then you can follow the instructions below to locate your database credentials in your Account Manager.
- Log in to https://www.web.com/my-account/login.
- On the left side of the page, click Hosting.
- If you have multiple hosting packages, select the package where you installed your WordPress, then click Manage.
- Navigate to the Configurations section, then click Database Manager.
- Take note of the Database Name, Server Name, and Username listed in the MySQL Database table.
How to Find My Database Credentials Via FTP
To find your database credentials via FTP, you need to:
- Connect via FTP and browse the WordPress site's root folder.
- Locate the wp-config.php file.
- Find the database name, database host, username, and password.
- Cross-reference the database information in the Account Manager with the information in the wp-config.phpfile.
Note: If the information does not match, the website files cannot connect to the database properly, thus having an “Error establishing a database connection” on your website.
How to Fix the Database Connection Error
Due to incorrect database credentials, your website fails to communicate with the database. You need to update the database connection string to resolve the issue and ensure data retrieval. Follow the steps below to fix the database connection error.
- Download the wp-config.php file using FTP.
- Fix the incorrect information.
Note: You can use a program such as Notepad to edit the file.
- Re-upload and overwrite the file with the corrected information.
- Check your website to see if the error is fixed.
A corrupted database contains data that has been altered to the point that it is no longer usable. This can be caused by faulty WordPress plugins or themes or by a hacking incident. If you have cross-checked that the database credentials in the Account Manager match those in the wp-config.php file, then a corrupted database may be the cause of the website error. The recommended action is to restore your website using a backup version of the database. Below are the steps for restoring your website files and database.
Select the option below:
WordPress Hosting Package
If you have WordPress hosting from us, then you can follow the instructions below.
- Log in to https://www.web.com/my-account/login.
- On the left side of the page, click WordPress.
- If you have multiple WordPress packages, select the package you want to fix, then click the Manage button.
- On the Security section of the WordPress Control Panel, click Backups.
- Select a backup version you want to restore, then click the Restore button.
Hosting Package that Uses WordPress
If you have WordPress installed in your hosting package, then you can follow the instructions below.
- Log in to https://www.web.com/my-account/login.
- On the left side of the page, select Hosting.
- If you have multiple Hosting packages, select the package where your WordPress is installed, then click the Manage button.
- In the Hosting Control Panel, navigate to the Configurations section, then click Website Backups.
- Select the daily snapshot you want to restore, then click Restore to Snapshot.
Review
This is an article about how to fix “Error Establishing a Database Connection” in Wordpress. It covers three possible causes of the error: incorrect database credentials, a corrupted database, and a deleted database. The article also provides instructions on how to fix the error in each scenario. Some important tips to follow are: back up your website before making any changes and verify the information in your Account Manager against the data in the wp-config.php file.
You can learn more about WordPress hosting with Web.com by visiting our storefront or finding additional troubleshooting tips here.