fbpx
Drag Click Play Pause Send Open Close

Web Wednesdays: How To Fix Error Establishing A Database Connection

News Web Wednesdays 4 minutes read July 31, 2019

Since being released in 2003, WordPress has become the go-to content management platform businesses and bloggers around the world can rely on. Nevertheless, as with anything, you may occasionally encounter puzzling errors which demand prompt diagnostics and repairs. This can be a daunting experience for any website owner, particularly for ecommerce businesses who could be missing valuable sales opportunities. One of the most frequent errors almost every WordPress developer has endured is the horrifying “Error establishing a database connection”. In this week’s Web Wednesday we take a look at this error and give you key advice to follow which can help to get your website back up and running.

Difficulty Level:
Difficulty Level

What Is This Error?:

Whether you’re installing a brand new WordPress website or “Error establishing a database connection” is abundantly displayed across your screen, you’re not alone in encountering this error. The error indicates a problem has occurred whilst connecting to your database and action is needed to rectify the error. There are several likely causes, which we discuss below.

Database Error

How To Fix “Error establishing a database connection”:

If you’re faced with this error, you may be feeling a little overwhelmed which is where we help! We’ve assembled a collection of helpful suggestions to assist you in getting your website back up and running which you can find below.

A Quick Glance:

  1. Examine your “wp-config.php” file to ensure the database details are correct
  2. Verify whether the error occurs on “/wp-admin/” and repair your database if relevant
  3. Contact your web host to check whether the server is experiencing problems

Let’s Take A Further Look:

Config Error

1. Examine Your “wp-config.php” File

One of the prime fundamental components to first consider exploring, notably if it’s a fresh website and database, is your “wp-config.php” file. Often the “Error establishing a database connection” error is prompted by incorrect database details detailed in this file. To remedy this issue, connect to your website files using an FTP client (such as FileZilla) and locate your wp-config.php file (this is located in the root folder). You should review the following details and ensure they are correct.

  • Database Name
  • Database Username
  • Database Password
  • Database Host

If you’ve adjusted the details, simply upload your updated config file and examine whether this resolves the problem. If you’re uncertain whether your configuration details are correct, you should reset your MySQL password manually via your hosting provider’s control panel. This should also specify the database host address to use. If this hasn’t solved the issue, follow the next steps below.

Login Screen

2. Verify Whether The Error Occurs On “/wp-admin/”

When facing this database connection error, you should attempt to access your WordPress dashboard via www.yourdomain.co.uk/wp-admin/. If you’re unable to enter your dashboard and the frontend of your website then the problem lies somewhere else and you should proceed onto our subsequent suggestion beneath. If however, you’re successfully able to access your dashboard or the error message presented is altered (such as “The database needs to be repaired”) then you should repair your database.

Before making any rash decisions, it’s worth getting a backup of your database, if you’ve not previously, incase something unfavourable follows. To repair your database, simply add the code placed below into your “wp-config.php” file. This can be achieved by utilising an FTP client, such as FileZilla, and editing your “wp-config.php” file found in the root folder.

define('WP_ALLOW_REPAIR', true);

Once edited and uploaded, visit www.yourdomian.co.uk/wp-admin/maint/repair.php to start repairing your database. Once your database has been repaired you should remove the new code recently appended to your config file. If this hasn’t resolved the error, please proceed onto our next solution.

3. Contact Your Web Host

In occasional circumstances your website could actually be perfectly fine, but rather a fault has suddenly transpired at your web hosts end. If the steps specified earlier haven’t resolved the problem, then we recommend contacting your hosting provider to query the error being displayed. They should be able to provide a more comprehensive summary of the current condition concerning your website, and also present information as to whether you might have exceeded your database quota or if your website is enduring high traffic volumes. They can also specify knowledge of any problems currently troubling their servers, as you may discover their server is momentarily down or having maintenance completed. Hopefully, your web hosting can present a better insight into the errors and identify the origin of the problems.

Finally:

If you’ve followed our tips above we hope you’ve succeeded in getting your website back up and running. In contrary fashion, if your website is still unwell, you could inevitably restore a backup of your website files and database or contact a professional web developer to examine the issue for you. If you have any questions or any suggestions which successfully worked for your website please feel free to let us know.

Additionally, please give our previous Web Wednesday’s article “How To Fix 5 Common WordPress Errors” a glance over. It addresses helpful solutions for 5 further common WordPress errors.


Posted in News, Web Wednesdays