How to Fix a Database Connection Error for WordPress
If your website ever runs into the following error:
You can verify that the database user and credentials are correct in your wp-config file.
Follow these simple steps to fix a database connection error for WordPress:
1. Log in to your control panel.
For instructions on how to log in to your DirectAdmin account, please click here.
For instructions on how to log in to your cPanel account, please click here.
2. Access File Manager within your control panel.
3. Access the public_html folder of your domain of where the WordPress files are installed.
4. Look for the wp-config.php file, then right-click the file and click Edit.
5. Look for the following code in the wp-config.php file.
Refer to the picture above.
‘exampleDBname’ is the name of your database.
‘exampleUsername’ is the name of the user assigned to the database.
‘exampleUserPW’ is the password created for the user.
These details have to match the database, user and password created in your MySQL Databases within your control panel.
6. To view your database details, head back to the control panel, then click MySQL Management.
7. Write down the full name of your database (in this example it is ‘datofumo_exampleDBname’) then select the database associated with your website.
This will now bring up details about the database, such as the users associated with it.
8. Write down the full database username. (In this example it is datofumo_exampleUsername)
Now would also be a good time to change the password if you are unsure of what the password is currently set to. Assuming we set the password to ‘exampleUserPW’ as per the wp-config.php file. (This will save you from having to make extra changes later on).
Head back to the wp-config file from earlier (From step 2 through to step 5)
Update the necessary values (if the values match up, no changes are required.)
See the example below.
DB_NAME and DB_USER names were updated.
DB Password remains the same, as we set the value to exampleUserPW earlier.
9. This should resolve your database connection error.
If you are still experiencing issues after trying the changes above, please log in to your MyDreamIT account and raise a support ticket to our team.
For instructions on how to raise a support ticket, please click here.