• Privacy Statement
  • DMCA Policy
  • Contact Us
  • Terms of Service
Friday, April 23, 2021
  • Login
Sande Kennedy
  • Home
  • General News
  • Africa
  • World
    • Europe
  • Sports
    • Football
    • Rugby Union
    • Cricket
    • Athletics
    • Athletes
  • Politics
  • Featured
    • Editorial
    • Blogs & Opinion
    • Commentaries
  • Technology
  • Entertainment
    • Celebrities
    • Sande TV
    • Movies
    • Sande Lyrics
    • Gossip
    • Campus Vibe
    • Arts
    • Events
No Result
View All Result
  • Home
  • General News
  • Africa
  • World
    • Europe
  • Sports
    • Football
    • Rugby Union
    • Cricket
    • Athletics
    • Athletes
  • Politics
  • Featured
    • Editorial
    • Blogs & Opinion
    • Commentaries
  • Technology
  • Entertainment
    • Celebrities
    • Sande TV
    • Movies
    • Sande Lyrics
    • Gossip
    • Campus Vibe
    • Arts
    • Events
No Result
View All Result
Sande Kennedy
No Result
View All Result

How to Fix “Error Establishing a Database Connection” in WordPress

Kennedy Sande by Kennedy Sande
2 years ago
in Business, Editorial, Technology
0
0
SHARES
0
VIEWS
Share on FacebookShare on Twitter

Seeing the dreaded,

“Error establishing a database connection”

RelatedPosts

Adobe CC 2019 Direct Download Links: Creative Cloud 2019 Release

Adobe CC 2019 Direct Download Links: Creative Cloud 2019 Release

September 30, 2020
Which TVs work with Apple TV app and AirPlay

Which TVs work with Apple TV app and AirPlay

August 21, 2020
Natural vs Synthetic Rope

Natural vs Synthetic Rope

August 17, 2020

…is the definition of a bad day if you’re a WordPress website owner.

Admit it, this error message looks quite serious. There’s no design, no familiar WordPress site elements, just text:

Error Establishing a Database Connection

First off, stop panicking!

I know that you’re probably a bit scared right now, but let me assure you that this problem can be fixed and any permanent damage can be prevented. In fact, the error establishing a database connection is quite common.

Understanding The Problem

As much as I don’t want to play Captain Obvious here, the nature of the error is self-explanatory – it’s an error establishing a database connection.

Here’s what it means exactly:

WordPress uses two main pieces of technology to provide you with all its awesome abilities: PHP and MySQL.

  • PHP is a programming language. WordPress – the core WordPress files – have been written in PHP. Boring, sorry.
  • MySQL is a database technology. WordPress uses a MySQL database to store all of your website’s content. This includes your posts, pages, but also the smaller elements, such as the title of your site, the layout of your widgets, the color settings, and etc. Basically, the MySQL database is where every, even the smallest piece of information about your website, is kept.

Putting the two together, WordPress uses PHP commands to connect to the MySQL database, get the information it needs, and then displays everything on the screen.

This is where the error comes into play. The error occurs when, for whatever reason, WordPress cannot access the information in the database via PHP commands. When that happens, WordPress basically doesn’t know what to do next, so the only thing it can say is, “Error establishing a database connection.”

With that being said, there can be a handful of reasons why the error occurs. Some of the more common ones:

  • Incorrect login credentials. WordPress needs a specific login and password to access the database. If those have changed for any reason then WordPress will no longer be able to fetch anything from the database.
  • Corrupted WordPress files. The core WordPress files can get corrupted as a result of a failed update, among others. This can include things like failed updates of the plugins, themes, and even the main WordPress software updates.
  • Corrupted database. This might be a result of a rogue plugin messing up the database internally, a hacker’s attack, a theme failing, and many more.
  • The database server is down. In some cases, the web server – the server that stores your website files – is run on a different machine than the database. And that separate database server can simply be down for whatever reason.
  • Too much traffic. Even though this is a good problem to have, it’s still a problem. Specifically, your database might be unresponsive due to a high spike in traffic. For example, maybe one of your posts went viral and now everyone and their dog tries to access your site? Hence the server is not able to handle part of those visits.

How To Fix “error establishing a database connection”

Since I value your time, I’m going to first recommend a path that’s the most likely to fix the problem for you quickly. Then, I’ll dig deeper and show you how to do all the fixes on your own manually.

Step 1: Get In Touch With Your Web Host Provider

Contact hosting support
Contacting your web host support is always a good idea…

It’s safe to assume that if your site was working just a minute ago (or a day ago) and now it isn’t then the fault can be on your web host’s end.

All quality hosts these days offer some form of fast-reacting support, usually through live chat.

Start by contacting that live chat, say that you’re experiencing an “error establishing a database connection” (paste the phrase), and ask:

  • if the database server is up and running with no problems, and
  • if there isn’t any spike in activity or traffic on the server right now.

In most cases, if you tell them what sort of error you’re having, they will either let you know what the cause is exactly, or they will even fix it for you.

Most importantly, they will let you know if your database is alright and whether or not there’s any suspicious activity on the server.

If the fault is not on their end (the server is operational and there are no spikes in traffic), and they don’t want to help you, proceed to step 2:

Step 2: Check If Your Plugin or Theme Files Haven’t Been Corrupted

Your WordPress files might get corrupted as a result of a couple of misfortunate events.

For instance, maybe you’ve updated a plugin or a theme, and the whole thing collapsed? Maybe you hooked the site up to an external service? Maybe you hand-edited some of the files?

If any of the above ring a bell, you probably have your culprit. If you haven’t done any of that, skip this step.

Here’s what you can do:

  • 1. First, connect to your host via FTP. You can do this with a free tool called FileZilla.

In order to connect, you need a login and a password to your FTP account. If you don’t know what/where those are, the easiest way to get them is to search through the initial emails that you got from your web host when you first signed up. Alternatively, you can ask the live chat support representative to give you those details.

Having them, connect to the server and navigate to the WordPress root folder. It’s usually called “public_html” or “www” or you might be in it already once you establish the FTP connection.

The rule of thumb is that if you can see sub-folders like “wp-content” and “wp-admin” then you’re in the WordPress root. Example:

WordPress root
  • 2. Go into “wp-content” and rename the “plugins” folder to something else (whichever other names, as long as it’s not “plugins”):
rename plugins
  • 3. Go back to your site and see if the error is still there.

If not, you now know that it’s been caused by some plugin. Go back to FTP, rename the folder back to “plugins”. Go in it, and change the folder names of the individual plugins, one by one. The easiest way to do this is to add an underscore at the end: “_”

name changed

Keep coming back to your site to see when the error gets triggered or vanishes. Once you’ve narrowed it down to one specific plugin, you have found the troublemaker. Either delete it or go online to see if the solution has been documented.

  • If the error is still there even after renaming the “plugins” folder, go through the exact same process with the “themes” folder.
  • If that doesn’t help, rename both folders back to “plugins” and “themes”. The error is caused by something else.

Step 3: Check If Your Database Hasn’t Been Corrupted

The WordPress database is a fairly complex thing, and there are a lot of small cogs that need to stay working together perfectly to avoid trouble. At times, something goes out of place and that’s when you see the error establishing a database connection.

  • 1. The first thing to check is to go to your WordPress dashboard – YOURSITE.com/wp-admin

If you see the same main error: “error establishing a database connection”, skip this step.

  • 2. If you see something else, pay close attention to what WordPress is suggesting you should do. In its recent versions, WordPress has expanded its problem-solving solutions, so you might see some good advice there. One of the possibilities:
admin error

Another possibility is that you’ll see a message starting with “One or more database tables are unavailable […]” This means that it’s you who needs to “repair” the database.

This is actually quite simple. First, connect to your site via FTP once again. Go to WordPress root and download the “wp-config.php” file to your desktop.

Edit this file in notepad, add one extra line at the end (right before “That’s all, stop editing”):

define('WP_ALLOW_REPAIR', true);

Now upload the file back to your site (via FTP) overwriting the old version.

Go to YOURSITE.com/wp-admin/maint/repair.php

This is what you should see:

database repair

Click either of the buttons. Once the automatic repair finishes, go back to your site and see if the error is still there.

If no error, great! But you still need to revert your “wp-config.php” file to its previous state. Remove that new line that you just added and re-upload the file.

If the error’s still there, next step is:

Step 4: Check Your Database Connection Credentials

As I mentioned, WordPress uses a specific username and password to connect to the database. Normally, those access credentials don’t change on their own. However, you can experience some weird scenarios after making any changes to your site files, the hosting environment, or anything else. In other words, even though it shouldn’t be happening, the access credentials sometimes do change. And with bad access credentials – “error establishing a database connection” happens!

The fix is done in the “wp-config.php” file. I’m talking about these lines specifically:

define('DB_NAME', 'some_db');
define('DB_USER', 'some_username');
define('DB_PASSWORD', 'some_pass');
define('DB_HOST', 'localhost');

They hold all the details that WordPress needs to connect to the database. If any of these are wrong, no connection will be established.

Note that there is a manual way of fixing this issue, but it honestly requires multiple steps and can be really confusing based on the web host you use and the interface they employ. In other words, anything I’d say here would still only be applicable to a small range of users who just happen to be using the same host as I am, so I have a much more universal solution for you:

Take those four lines from the “wp-config.php” file, simply copy them to the clipboard, contact your web host support again, paste those lines in the chat window and ask if the details are correct for you to be able to connect to your database.

The representative will check everything, and come back to you with some feedback. Most often, they will provide you with the correct details in case anything has been changed.

All you need to do is take the new credentials and put them in your “wp-config.php” file where the old ones used to be.

define('DB_NAME', 'some_db'); /* this is the name of your WordPress database */
define('DB_USER', 'some_username');
define('DB_PASSWORD', 'some_pass');
define('DB_HOST', 'localhost'); /* this is the web address of your database server */

Finally, re-upload the file via FTP.

At this stage, you can go back to your site and see if the error has been fixed.

If not, I have one final step for you:

Step 5: Restore The Default WordPress Files

As I mentioned before, the core WordPress files can get corrupted for a number of reasons. Maybe there’s been a hacking attempt on your site, maybe you modified some files by accident, maybe a rogue plugin did the modification.

Whatever it might be, you can still restore the default, native files of WordPress. The easiest way to do that is to just download a clean version of WordPress from WordPress.org and copy it over the one you have right now.

Go here, and download the newest package to your desktop. Unpack. Browse through the unpacked archive and delete the “wp-content” folder.

Next, connect to your site via FTP, go to the main WordPress root, upload your new WordPress files. Overwrite all the previous files.

upload new WordPress files

When the upload is done, go back to your site and see the effect.

This is a last resort kind of fix. If this doesn’t help, you will have no other choice than coming back to your web host support line, tell them everything that you’ve done and ask for help. At this stage, you’ve basically exhausted everything you could do to fix the issue yourself and it’s the host’s turn to solve it. You’re paying your hosting bills after all, aren’t you?

How To Avoid This Error In Future?

While there isn’t a 100% fail-proof way to protect your site against any error establishing a database connection, there are two main elements that you should have in your insurance puzzle to be at least 90% safe:

  • Quality hosting. Work only with hosts that have optimized their platforms to work with WordPress. That way, you can always count on the knowledgeable support and fast help. Not to mention that you will also avoid many common WordPress problems. Here are my recommendations.
  • Have backups. Install a simple backup plugin like UpdraftPlus (it works automatically) and you should always have a working WordPress backup that you can restore in case everything else fails.

I hope this guide helps! And as always, feel free to reach out to me if you’re having some tough time with an error establishing a database connection.

Related Posts

Adobe CC 2019 Direct Download Links: Creative Cloud 2019 Release
Business

Adobe CC 2019 Direct Download Links: Creative Cloud 2019 Release

September 30, 2020
Which TVs work with Apple TV app and AirPlay
Technology

Which TVs work with Apple TV app and AirPlay

August 21, 2020
Natural vs Synthetic Rope
Business

Natural vs Synthetic Rope

August 17, 2020

About Us

We bring you the best news un Kenya. Check our landing page for details.

Learn more

Recent Stories

  • Chad President Idriss Deby has died: Army spokesman April 20, 2021
  • Naomi Osaka crushes Serena Williams in stunning battle to book place in Aus Open final February 18, 2021
  • Garissa Senator Yusuf Haji is dead February 15, 2021
  • Former Chief Justice Evan Gicheru dies December 26, 2020
  • Mount Kenya University online courses November 16, 2020
  • How to get and use 1xBet promo code October 22, 2020
  • Twitter CEO Jack Dorsey tweets his support for #EndSARS protest October 15, 2020
  • Two feared killed, others injured as SUV rams into #EndSARS protesters in Lagos (graphic video) October 15, 2020
  • Apple iPhone 12 Pro Max full phone specifications October 14, 2020
  • Apple announces iPhone 12 and iPhone 12 mini: A new era for iPhone with 5G October 14, 2020
  • Mulamwa and Sonie calls it Quits October 8, 2020
  • London Marathon 2020: Eliud Kipchoge beaten as Shura Kitata takes the title October 4, 2020
  • Former NTV reporter Lolani Kalu offered more than seven jobs October 1, 2020
  • Adobe CC 2019 Direct Download Links: Creative Cloud 2019 Release September 30, 2020
  • See the Amount of money Kenyans have raised for Lolani Kalu September 30, 2020
  • Kuwait’s 91-year-old ruler Sheikh Sabah al-Ahmad al-Jaber al-Sabah has died. September 29, 2020
  • Former NTV journalist Lolani Kalu not doing well ever since he lost his job. September 29, 2020
  • Laycon wins the 2020 Big Brother Naija reality show September 27, 2020
  • List of ethnic groups in Tanzania September 27, 2020
  • Covid-19: Kenya records 38,115 cases after 244 more test positive September 27, 2020
  • ODM has suspended MP Owen Baya disloyalty September 27, 2020
  • We use them without knowing their meaning Useful information August 29, 2020

Categories

  • Amazon (14)
  • Animals (10)
  • Apple (138)
  • Art & Culture (14)
  • Blogs & Opinion (479)
    • Cartoons and Art and Design (1)
    • Commentaries (37)
    • Editorial (203)
    • Letters (2)
    • Sandes View (1)
  • Bunge La Mwananchi (14)
  • Business (896)
    • Agriculture (6)
    • Budget (41)
    • Construction (20)
    • Consumer (138)
    • Corporates (108)
    • Enterprise (151)
    • Finance News (201)
    • Technology (673)
  • Campus Vibe (31)
  • Celebrity Net worth (144)
    • Athletes (5)
    • Businessmen (23)
    • Celebrities (74)
    • Politicians (39)
  • Crime Alert (27)
  • Culture (2)
    • Movie (2)
  • CYBERSECURITY (1)
  • Entertainment (65)
    • Arts (9)
    • Books (7)
    • Movies (11)
    • Sande Lyrics (15)
  • Events (2)
  • Extreme (2)
  • FACEBOOK (1)
  • Family (10)
  • Food (7)
  • General News (1,384)
  • Google (3)
  • Gossip (4)
  • Health (11)
  • Kenya (235)
    • Central (16)
    • Coast (20)
    • Eastern (16)
    • Nairobi (22)
    • North Eastern (16)
    • Nyanza (18)
    • Rift Valley (20)
    • Western (17)
  • Kitchen Appliances (1)
  • Men (8)
  • MOBILE PHONES (6)
  • Money (6)
  • News (9)
    • Business (2)
    • World (6)
  • nsfw (1)
  • Obituaries (12)
  • ODM PARTY (4)
  • Paginated Post (1)
  • Politics (253)
    • BBI (13)
      • Ali Hassan Joho (3)
    • JUBILEE PARTY (8)
    • Raila Odinga (13)
    • Uhuru Kenyatta (11)
  • Qatar (104)
    • Ad Dawhah (Doha) الدوحة (66)
    • Al Daayen الضعاين (64)
    • Al Khor الخور (64)
    • Al Rayyan الريان (64)
    • Al Shamal الشمال (63)
    • Al Wakrah الوكرة (64)
    • Al-Shahaniya الشحانية (64)
    • Umm Salal أم صلال (63)
  • Recipes (3)
  • Sande TV (1)
  • Showbiz (8)
  • Sports (4)
  • Technology (7)
  • Travel (39)
  • Uncategorized (58)
  • Women (13)
  • Women & Style (21)
  • World (528)
    • Africa (206)
      • Algeria (2)
      • Angola (2)
      • Benin (1)
      • Botswana (1)
      • Kenya (19)
      • Pan Africanism (130)
    • America (7)
    • Antarctica (3)
    • Asia (12)
    • Europe (9)
    • Featured (34)
    • Sports (75)
      • AFL (1)
      • Athletics (8)
      • Basket Ball (3)
      • Cricket (1)
      • Football (61)
      • Golf (1)
      • Hockey (1)
      • MMA (2)
      • Motor Sport (1)
      • Net Ball (1)
      • Other Sports (2)
      • Racing (1)
      • Rugby Union (1)
      • Tennis (1)
    • World (153)
  • Privacy Statement
  • DMCA Policy
  • Contact Us
  • Terms of Service

© 2021 Sande Kennedy - Read More Guides SK.

No Result
View All Result
  • Home
    • Home – Layout 1
    • Home – Layout 2
    • Home – Layout 3
  • Landing Page
  • Buy JNews
  • Support Forum
  • Pre-sale Question
  • Contact Us

© 2021 Sande Kennedy - Read More Guides SK.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Cookie settingsACCEPT
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.
Necessary
Always Enabled

Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.

Non-necessary

Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.

SAVE & ACCEPT

We are using cookies to give you the best experience on our website.

You can find out more about which cookies we are using or switch them off in settings.

Sande Kennedy
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

Strictly Necessary Cookies

Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.

If you disable this cookie, we will not be able to save your preferences. This means that every time you visit this website you will need to enable or disable cookies again.

Cookie Policy

More information about our Cookie Policy