Wordpress error establishing a database connection – localhost xamp, wamp [Solved]

by admin
error establishing a database connection

While using WordPress sometimes you might have faced the error establishing a database connection on your localhost. This happens to a lot of users and mainly faced by the WordPress beginners.

So, if you have encountered with this problem and want to know how it can be fixed then follow this step by step guide. These steps are common and work for all local or live servers like xamp, wamp, aws, digital ocean, docker, hostinger etc.

error establishing a database connection

5 Steps to Fix Wordpress error establishing a database connection

This error indicates that the database is not linked to the WordPress site. For this problem to be fixed, the database must be connected to the WordPress website.

The MYSQL database is not linked to the website because the MYSQL database login credentials are incorrect; if this is corrected, the error will be resolved. When you first start using WordPress, you’re going to run into various issues, some of which are serious, while others aren’t.

 It’s unavoidable; it might be a flaw, a system failure, someone failing at their job, natural disasters — anything could produce an error. These are the steps for correcting an error establishing a database connection.

Step 1: Contact the Web Hosting Provider

If the site was operating only a minute (or a day) ago and isn’t now, it’s safe to presume that the problem is with the web host. These days, all good hosts provide some fast-response help, usually via live chat.

Start by calling that live chat, explaining that you’re having an “error establishing a database connection in wordpress” (paste the phrase), and asking if the database server is up and functioning without any issues, and if there isn’t any current spike in activity or traffic on the server.

Step 2: Verify that the Plugin or Theme Files aren’t corrupted

As a result of a few unfortunate situations, WordPress files may become corrupted. If these sounds familiar, you have probably found the error. If you have already skipped any of the above, you can skip this step also.

To connect, you’ll need the FTP account’s login and password. If you don’t know what/where they are, the most straightforward approach to find them is to look through the initial emails, you received from the web host when you signed up.

  • Second, go to “wp-content” and rename the “plugins” folder to something else (anything goes as long as it isn’t “plugins”):
  • Third, return to the site to see if the problem persists.

It’s the result of a plugin. Return to FTP and rename the folder to “plugins.” Change the folder names of the different plugins one by one in there.

Step 3: Make Sure the Database Isn’t Corrupted

The WordPress database is a complicated system with many small cogs that must all operate together flawlessly to avoid problems. When things aren’t quite right, you’ll notice a problem establishing a database connection.

Another possibility is that you’ll see a warning that begins, “One or more database tables are unavailable.” This implies that it is they who must “fix” the database.

Step 4: Check the xamp error establishing a database connection Credentials

WordPress connects to the database using a unique username and password, as previously indicated. You can check wp-config file too and cross-check those access credentials.

In wp-config check for database creds like:

  • Db name: Write a database name that you have created in MySQL
  • User name: it would be “root” and if it is live server the name would be different.
  • Password: if have set any password then put it here or leave it blank.
  • 1 more thing important, look for the prefix wp_ or whatever you want to add!

However, after making any modifications to the site files, the hosting environment, or anything else, you may see some strange scenarios. In other words, even though it shouldn’t, access credentials change from time to time.

Step 5: Restore the WordPress Default Files

The core WordPress files can become corrupted for a variety of reasons, as we previously explained. The site may have been hacked. Whatever the case may be, WordPress’ default native files can still be restored.

Still you facing the issue?

If you are unable to fix the issue on your localhost or on live server then you can contact us via skype. We will check and fix it!

Related Posts

Leave a Comment