Latest Posts
Home =>> Fix Error =>> Fix Wordpress Error =>> How to Fix the Error Establishing a Database Connection in WordPress
wordpress database connection error

How to Fix the Error Establishing a Database Connection in WordPress

For the wordpress beginners, this Error Establishing a Database Connection error makes a little uncomfort.This error may comes due to deletion of tables in your database ,or in wp-config.php if the entered database values are incorrect. We’ve searched many websites , forums about this error but no one has provided a solution in an easy way.In this article we are listing you the main causes for Error Establishing a Database Connection error and how to push out them easily.It is a just 5 minutes program to fix the error.

1.Database Repair

2.Problem in wp-config.php file.

3.Problem with wp-options.

Note: Before doing all this please take a backup of your website.

First Let us go with

1.Database Repair….

This happens only when you delete some tables in your wordpress website database.You can fix this by simply adding below codedefine 'WP_ALLOW_REPAIR', true); to your wp-config.php file ,then save the file. You can see the following page after refreshing your website url.

database-repairThen click on either Repair database or Repair and Optimize Database.It will repair your database and adds deleted default tables to your database.Finally your error will be fixed.If not fixed with step 1,then go with step 2.

2.Problem with wp-config.php
The main part we have to check DB NAME,DB USERNAME, DB PASSWORD, and DB HOST.Check the queries in wp-config.php,you can find this wp-config.php file in home directory.Check the below code

define ('DB_NAME','database-name');

define ('DB_USER','database-username');

define('DB_PASSWORD','database-password');

define('DB_HOST','localhost');

Replace your database @’database-name’,database username @’database-username’

user password @ ‘database-password’ and default localhost @’localhost’

That’s it your error will be fixed with this.If not go with step 3.

3.Problem with wp-options table in your database

Check with wp-options table in your database by using phpMyAdmin.check your table content whether your site url is correct or not.If not, replace with your current website url.Or else you can run with following queries

UPDATE wp_options SET option_value='YOUR_SITE_URL' WHERE option_name='siteurl'

Replace YOUR_SITE_URL with your current website URL.
With this 3 steps we hope your error will be fixed. Happy Coding..!!

Note: Before doing all this please take a backup of your website.

 

Leave a Reply

x

Check Also

Creating magento customers custom group,

Steps to Creating Magento Customer’s Custom Groups

Create a Magento Customer’s Custom Group Setting up a custom user group in magento is very easy. You can create a new group from the admin admin area of Magento. You just go to Admin ...