How to Fix the Error Establishing a Database Connection in WordPress
What Causes Error Establishing a Database Connection in WordPress?
The “error establishing a database connection” is probably one of the most common and frightening errors that WordPress users can encounter. This error means your website is no longer communicating or has access to your WordPress database, and thus your entire website goes down. This is not something to be taken lightly and you should try and resolve this immediately as this can directly affect your sales, traffic, and analytics.
But don’t worry, today we’ll discuss How to fix Error Establishing A Database Connection.
The ‘Error establishing a database connection’ issue can be caused by incorrect database information in your WordPress settings, corrupt database, or an irresponsive database server.
As a content management system, WordPress uses a database to store all your content and other website data. It then connects to the database each time someone visits your website.
So that you have to check following details,
- Database name
- Database username
- Database password
- Database server
Make sure that the following conditions are met,
- Database name matches the existing database name
- Username of the assigned database user matches the existing database username
- Password matches the one assigned to the specified database user
- Specified user has access privileges to the site’s database.
1. Check Your WordPress Database Credentials
Database name, database username and its password can be found in the wp-config.php file located in the root directory of your WordPress installation. In order to check these details, do the following,
- Log into your cPanel and Click on File Manager. Move to the root folder for your site, WordPress installation.
- Click on the wp-config.php file with the right-mouse button and select Edit or View option.
Once you have found the database details in the wp-config.php file, the next step is to check if they are correct.
2. Check your MySQL Databases in cPanel
In cPanel click on MYSQL Databases and Carefully check if there is a database which name fully matches the one specified in wp-config.php file. If not check the all details which one matches or handle WordPress site.
Then scroll down and check the database username.
3. How to Fix the Error Establishing a Database Connection in WordPress
Now you need to make sure that the information for the database name, username, password, and database host is correct.
- Check data base name matches to (wp-config.php) database name
- Check data base username matches to (wp-config.php) database username
- Check data base password matches to (wp-config.php) database password
- Check data base host matches to (wp-config.php) database host
So that let’s change the password of the MYSQL User.
Find the user who handle your WordPress site then change the password.
Set New password.
Select all and Click on Make Changes.
Now set the all details in wp-config.php file. Make sure that the information for the database name, username, password, and database host is correct.