The error establishing a database connection issue occurs when your website no longer has access to your WordPress database. This issue can have serious consequences if left unattended. It can directly affect your website traffic leading to revenue and sales loss.
With this blog, we will look into some of the reasons that cause error establishing a database connection issue to appear and the possible ways to get this issue resolved.
Follow us on LinkedIn to stay updated on the latest support articles and information we share.
Error Establishing a Database Connection in WordPress – Causes
1. Wrong Database Information
The database makes it easy to organize, retrieve and store the data. If someone visits the website, the site automatically connects to the database. However, in certain scenarios, a database connection error appears in the WordPress website, when the site isn’t able to access the WordPress database due to incorrect login credentials provided.
2. Corrupted Files in WordPress
A failed update can corrupt WordPress files. Failed updates of WordPress plugins, themes, or WordPress software can result in WordPress files getting corrupted. A corrupt WordPress file can be due to any internal database mess formed due to the rogue plugin, an attack by the hackers, and other reasons.
3. Corrupted Database in WordPress
Database files getting corrupted or accidental deletion of some information are other reasons that cause the “error establish a database connection” issue to appear on your WordPress website. Third-party plugins used in WordPress websites may also auto-delete content or break file paths leading to database connection errors.
Steps to Fix the Issues Causing the “Error Establishing a Database Connection in WordPress
Following the steps mentioned below will help you resolve database connection issues. To be on the safer side, you can take a backup of your WordPress site before you start troubleshooting the error.
1. Get the Database Information Correct
As we discussed earlier, incorrect database login information is the most common reason that causes this error. Moving your website to a new web host might have resulted in a change in login credentials.
The credentials for your WordPress database are stored in the wp-config.php configuration file. This file is located at the root of your WordPress website. This WordPress file contains all your database information and important settings. Database information such as database name, password, username and host details provided in the configuration file should be correct. If not, edit the configuration file and update the new credentials to resolve the issue.
To access the configuration file, try connecting to your website via SFTP and go to the root directory. You can also edit the file on cPanel by going to the root directory.
2. Fix Issues with WordPress Files
A failed WordPress plugin, theme, or WordPress software update can cause the files to get corrupted. To resolve any issue related to the plugins, you can connect to your site through FTP and navigate to the root directory.
From there you can select “wp-content”. Inside the wp-content folder, you can find another folder named plugins. This is the location where WordPress stores all your installed website plugins. Select that and rename it to any other names that you like.
Finally, you can go back to your WordPress site and check if the issue still exists or not. If the error was due to the plugin issue, the site won’t be showing the error gain.
If you are still getting, “error establishing a database connection in the WordPress” message again, try checking the theme files for any issues. You can download a new copy of the theme files and see if it helps.
Still, if you are not able to get the issue resolved, it is better that you contact any WordPress management services provider for help. ServerAdminz has a team of WordPress experts who can help you resolve this issue quickly.
3. Fix the Corrupted Database
There are chances that your database has gone corrupt. So in case if you are and getting an error message similar to “one or more database tables are unavailable” on the wp-admin, then there might be some issues with the database.
To resolve the issue, you can connect to your WordPress site via FTP as mentioned earlier, and go to the WordPress root directory. From there you can now download the configuration file “wp-config.php” to your desktop.
Edit the downloaded file and add the following code to the bottom of the file.
define(‘WP_ALLOW_REPAIR’, true);
After adding the code, go to the WordPress database repair page- https://example.com/wp-admin/maint/repair.php.
Here example.com stands for your website’s name.
Once logged in, you will see an option to repair your database. Once you complete the process, your website will be up and running without any issues.
Other Solutions to Fix the Issue of Error Establishing a Database Connection
1. Restore Core WordPress files
Replace your core WordPress files, by downloading a clean version of WordPress software from WordPress.org. This is the last kind of method that you can use to resolve the issue on your own. If you don’t have the right technical expertise to do this, you can take the help of any WordPress support provider.
2. Take the Help of Technical Support Service Providers
The troubleshooting steps involve doing lots of technical things. Hence it is better you take the help of a technical support service provider. They have the right expertise required to help you resolve the issue quickly and efficiently.
Related Article: How To Solve WordPress 403 Forbidden Error
Wrapping Up
There are various scenarios due to which you may get the “error establishing a database connection in WordPress” message. Wrong database credentials in the configuration file, database file corruption are some of the common reasons that cause this issue.
With this article, we have discussed some troubleshooting steps to fix the issue. We hope these methods will help you resolve the issue of database connection error in WordPress.
Leave A Comment
You must be logged in to post a comment.