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.
How to Fix the Error Establishing a Database Connection in WordPress
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 you have to check the following details,
- Database name
- Database username
- Database password
- Database server
Make sure that the following conditions are met,
- The database name matches the existing database name
- The 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 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 the 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 whose name fully matches the one specified in the wp-config.php file. If not check the all details to which one matches or handles the 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 database name matches to (wp-config.php) database name
- Check database username matches to (wp-config.php) database username
- Check database password matches to (wp-config.php) database password
- Check database host matches to (wp-config.php) database host
So let’s change the password of the MYSQL User.
Find the user who handles your WordPress site then change the password.
Set a new password.
Select all trigers and click on Make Changes.
Now set all details in the wp-config.php file. Make sure that the information for the database name, username, password, and database host is correct.
If you have any problems please comment below, We are always here to help you. And also share your ideas with us!