When WordPress cannot connect to the database, an error message titled “Error Establishing Database Connection in WordPress” will show up and is one of the most common WordPress errors. This could be caused by a number of things, including incorrect database login information, a shaky web host, or a problem with the database server itself.
How to fix Error Establishing Database Connection in WordPress?
To fix this error, you can try the following steps:
- Make sure the database login information in your wp-config.php file is accurate. You must access the file via FTP or your hosting control panel to verify the database login information in your wp-config.php file.Search for the following lines of code in the wp-config.php file after accessing it:
The DB NAME, DB USER, and DB PASSWORD variables must be accurate and correspond to the database name, username, and password you use to access your database. Update any wrong values and save the modifications to the wp-config.php file.
You can ask your web host for advice if you’re unsure of what the right values should be. They ought to be able to give you the proper database login information.
- To verify that the database server is functioning properly, speak with your site host.
- If the problem continues, try adding the next piece of code to your wp-config.php file to fix the database:define(‘WP_ALLOW_REPAIR’, true);
This will enable you to access “http://yourdomain.com/wp-admin/maint/repair.php” and run the WordPress database repair tool. Be sure to remove that line once your issue is resolved.
- You might need to restore your website from a backup if none of the methods above are successful.
In conclusion, although there are a number of potential causes for the Error Establishing Database Connection in WordPress, it is typically brought on by faulty database login information, a shaky web host, or a problem with the database server. You should be able to fix this problem and get your website back up and running by following the above-listed instructions. Hope this helps.