Error Establishing a Database Connection

While using WordPress, you might encounter a number of errors. Some can affect your system and some can be ignored easily. If you are getting an error establishing a database connection, then you need to resolve it immediately otherwise your website will not appear online.

In this blog, we will describe how can you resolve “error establishing a database connection”. But, before jumping into how to fix the establish database connection error. You need to know how this error comes into your WordPress website.

INCORRECT LOGIN CREDENTIALS

Database error issue might arise because of incorrect login username and password. If username and password has been changed recently, then you are not able to access your database with old names. Thus, you need to confirm the login credentials while entering it.

DATABASE IS CORRUPTED

You need to check that WordPress database is working or not. It might be corrupted because of several reasons like installing a faulty or incompatible plugin. Secondly, your hosting server may be down.

CORRUPTED FILES

Check all the files in your WordPress to resolve the error. If you do any change in any file of WordPress, then make sure it does not affect the process of database connection else restore the file.

LOW QUALITY HOSTING PROVIDER

Your site may be hacked or down due to heavy traffic. Thus, always select high-quality hosting provider for preventing this issue.

These can be some reasons to get an error in your WordPress website. After knowing the reason of error, you are required to fix it. Here are some steps given below which will help you fix this error and get your site back up online.

Step 1: Check If Database Is Corrupted

You need to check that your database is working or not. If you find your website is normal and get an error while trying to access the WP-admin page or get an error message like one or more tables are not available. Then you need to repair the database. With the WordPress built-in features, you can easily recover your WordPress website.

  • You are required to enable this feature as by default it is disabled.
  • For this, go to the WP-admin.PHP file and add this code:

define( ‘WP_ALLOW_REPAIR’, true )

Once you write line, you are able to optimize your database. After that, you will have to navigate to

www.yoursite.com/wp-admin/maint/repair.php

You will see this type of page format:

repair database

Note: The Repair and Optimize database error takes more time to recover as compared to simple Repair Database. Thus, you can choose the first option.

 

  • Now go back to your site and check error is still there or not.

Great…you have recovered your database error.. If error still exists then go to next step:

Step 2: Check Your Database Login Credentials

To open the WordPress dashboard, you need to use correct username and password. But, if you do any change in your hosting files, WP-config files or anything else then there might be possibility that you are not able to open your WordPress dashboard. With wrong access credentials, you will get a message that “error establishing a database connection”.

To resolve this issue you are required to check the wp-config file: It is the most important file in your entire WordPress installation and it will play a major role for WordPress to connect your database. If you change any password in your WordPress like root password, then you will have to change in the wp-config file

Here are the some steps given below:

define(‘DB_NAME’,’database-name’);
define(‘DB_USER’,’database-username’);
define(‘DB_PASSWORD’,’database-password’);
define(‘DB_HOST’,’localhost’);

Now, you need to check the database host vale, it might be local host or not. Depending on the distinct host, it will vary. You can find the host value by visiting the website of a particular host.

Step 3: Get In Touch With Your Web Host Provider

If suddenly your WordPress website stops working then the problem can be on your web host’s end. At that time, you need to immediately contact your web host provider through phone , email support, and live chat and tell them you’re experiencing an “error establishing a database connection”. They will either let you know what the cause is exactly, or they will even fix it for you by providing better solution to fix the error.

If fault is not from the hosting end then they are not able to fix the issue. Then, proceed to the next step:

Step 4: Check Your WordPress Theme File

You may get an error message due to some corrupted files in WordPress like you have updated WordPress theme or plugins or you hooked the site up to an external service.

To fix this issue, you need to follow below steps:

  • First, connect to your host via FTP or by using FileZilla tool.
  • Go into “wp-content” and rename the “plugins” folder.

Simple rename

Now, check the WordPress site if there is still an error then go to the theme folder and do the same process which you have done with plugins.

Step 5: Restore The Default WordPress Files

Because of some hacking attempts, some WordPress files can be corrupted then you may face an error like “error establishing a database connection”. Then, you may restore some default file and can establish the database connection. Also, if you have gone for html to WordPress conversion, then make sure it is error free.

For this:

  • Download the fresh version of WordPress from the WordPress.Org and copy it where you have put your existing one.
  • Then, download the newest package to your desktop.
  • After browsing unpack folder, delete the wp-content folder.
  • After that, you will have to connect your website via FTP and go to the main WordPress root and upload the new WordPress files.
    Here, you will have to overwrite all the previous WordPress files.

Conclusion

We suggest you before choosing WordPress for your website, firstly choose quality hosting provider.

Hope, above steps provided by us would be helpful for you to resolve your issue related to WordPress error. If still you face any issue for WordPress development then you can reach out to CSSChopper without any second thought. Here, you will find a WordPress support team which will help you fix your issue with an error establishing a database connection.

Ready to get started? Fill the form now!

Related Posts

z
 

Looking for a Web Development Services?

Request a FREE Quote.