• Home
  • About
  • Blog
  • Advertise
  • Contact
No Result
View All Result
Ideasgist
NEWSLETTER
  • Home
  • MediaHot
  • Education
    • School
    • Jamb
    • University
    • Polytechnic
    • College of Education
  • TechnologyNew
  • NewsTrending
    • Politics
    • local
    • world
  • Sport
  • Entertainment
    • Media
  • Lifestyle
  • More Topics
    • Business
    • Banking
    • Telecom
    • Job
  • Home
  • MediaHot
  • Education
    • School
    • Jamb
    • University
    • Polytechnic
    • College of Education
  • TechnologyNew
  • NewsTrending
    • Politics
    • local
    • world
  • Sport
  • Entertainment
    • Media
  • Lifestyle
  • More Topics
    • Business
    • Banking
    • Telecom
    • Job
No Result
View All Result
Ideasgist
No Result
View All Result
Home Tech Reviews

How to Fix Error Establishing a Database Connection in WordPress

by Oluwaseyi Olaniyi
October 6, 2020
in Reviews, Tech
Reading Time: 7min read
A A

How to Fix Error Establishing a Database Connection in WordPress: Knowledge is power, one of the most frustrating issues you might come across in wordpress is the “error establishing a database connection” nevertheless I am here with a solution on how to fix this error. New to my website?  My name is yanke I am dedicated wordpress solution solving blogger and I always tutor my site users on how to go about their wordpress blog.              

Are you currently seeing the error I mean are you having an error issue relating to the topic “Error establishing a connection”? If yes then I have got the solution for you. This error is a fatal error that makes your wordpress website inaccessible to the users. This error only occurs when wordpress is unable to make a connection to your database.


In this article I would show you how to successfully fix this error.

Let get started.

AlsoRead:

Bitcoin Moves Past $51,500

iPhone 12 MagSafe-Compatible Battery Pack May Support Reverse Charging

WhatsApp Messenger Gets New Animation For Voice Messages And Disable Receipts On iOS With Latest Update

First let’s look at the causes in other to avoid it next time.

This error issue can be caused by incorrect database information in your wordpress blog settings, either corrupt database or an irresponsive database server.

What is a database: database is software which makes it easy to store, retrieve and organize data info into other software/program.


WordPress is a content management system (CMS) and it uses a database in other to store all contents and other website data. It connects to the database each time a site user visit your wordpress blog/website.

In other to connect to the database your wordpress site needs the following information:

  • Database username
  • Database name
  • Database password
  • Database server normally “localhost”

This info’s is stored In your wordpress configuration fill known as “wp-config.php”, if any of the mentioned items are incorrect wordpress would fail to connect to your database, which would result to an error establishing a database connection message”.


These errors can also be caused by a database server downtime or corrupt database.

In this article I would be explaining how to fix this error with a step by step troubleshooting.

Step 1. Check if wordpress database credentials are in correct.

Fixing Error Establishing a Database Connection in WordPress
Fixing Error Establishing a Database Connection in WordPress

Incorrect credentials are one of the most common reasons for database connection error. If you recently moved your wordpress blog to a new host this can likely be the reason.

Database credentials are normally stored in the wp-config.php file. This is the wordpress configuration file that contains all important wordpress settings including your database information.

If this is your first time editing a “wp-config.php” file then you have be very careful while editing.

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

Login to your control panel and locate where your wordpress files where installed, navigate to the wp-config.php file and locate the following codes shown below.

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'database_name_here' );
/** MySQL database username */
define( 'DB_USER', 'username_here' );
/** MySQL database password */
define( 'DB_PASSWORD', 'password_here' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' );

Run a check on the database name, username, password and database host make sure it’s correct.

You can confirm this information for your wordpress hosting account dashboard. Login to your hosting account and locate the MYSQL database. This will take you to a new screen displaying the database management page in your hosting dashboard. On that page you can find out your database and username. You can change your user password over there then return back to the “wp-config.php” file and fill in the new password.

Make sure to save the config.php file then try loading your site again.

If you still seeing the error then that was never the issue.

2. Run a recheck on your database host information.

Let’s check if the database host information is correct as well. 99% wordpress hosting companies make use of “localhost” as your database host. How er some companies use separate serves to host databases. In that case your database host will not be localhost. Best way to figure out your hosting database host is to contact your hosting company in other to confirm your database host information. If you using namecheap, bluehost or godaddy then “localhost” is certainly your database host.

3. Repair your wordpress database

In this case if you getting a different message entirely on the wp-admin dashboard for instance message related to “one or more database tables are unavailable. The database may need to be repaired, meaning you have to repair your database. You can resolve this by adding the following line in your wp-config.php file. Make sure to add it.

define('WP_ALLOW_REPAIR', true);

Once you done you should see the settings by visiting the page of your website: http://www.yoursite.com/wp-admin/maint/repair.php

You do not need to be logged in to access the database repair page. Once repair and optimization are done, make sure to remove the code you recently added from your wp-config.php.

4. Run a check if your database server may be down

If after running all first three methods and wordpress till cannot connect to the database, then your database server (MYSQL sever) may be down.   

This normally occurs when there are heave traffic on a server. In other words this means your host server just cannot handle the load most especially if you on a shared hosting plan.

The best solution is to get your phone call place a call to your hosting customer care or live chat with your hosting provider and ask them to help fix or run a check on your “MYSQL” server or ask if it’s responsive.

If you have other sites running on same server/host then you can as well run a check on those sites confirming if your SQL server is down. If this other sites hosted on your servers are showing same errors then it means your SQL server is down.

.if you do not have any other sites hosted on the server then simply go to your hosting account dashboard and try accessing “PHPMYADMIN” and connect the database.

If you can connect, then we need to verify if your database user has sufficient permission. Create a new file called testconnection.php and paste the following code in it:

<?php
$link = mysqli_connect('localhost', 'username', 'password');
if (!$link) {
die('Could not connect: ' . mysqli_error());
}
echo 'Connected successfully';
mysqli_close($link);
?>

Make sure to replace the username and password. You can now upload this file to your website and access it via web browser.

If the script works or connected successfully, then it obviously means that your user has sufficient permission, something else is wrong.

Return back to your wp-config file to make sure that everything is in perfect order. Make sure to re-scan for typos.

These are other solutions that have worked for me before.

  1. Try updating your wordpress site url
  2. Try rebooting your web server
  3. Ask for help by contacting your host provider.

Follow Ideasgist Now on Facebook and Twitter. Also join in for Latest News, Tech News, Media and lot more.

SUBSCRIBE TO OUR NEWSLETTER





Tags: Databasewordpress
ShareTweetSendShare
Oluwaseyi Olaniyi

Oluwaseyi Olaniyi

Related Posts

App

Apple Blocked Updates To Free WordPress App

August 22, 2020
Load More
  • Trending
  • Comments
  • Latest
How to block your bank account with code if ATM card is stolen

How to block your bank account with code if ATM card is stolen

November 24, 2020
I Suffered From Depression, Attempted Suicide After Losing My Mother – Actress Nancy Isime

I Suffered From Depression, Attempted Suicide After Losing My Mother – Actress Nancy Isime

February 26, 2021
Shake-up Imminent In EFCC As 850 Police Personnel May Return To Force Duties

Shake-up Imminent In EFCC As 850 Police Personnel May Return To Force Duties

February 22, 2021

FRESHERS: How To Check Your Matriculation Number

May 3, 2019
Frustrated Chelsea Waste Chance To Move Into Top Four After Clash End Goalless Against Man Utd

Frustrated Chelsea Waste Chance To Move Into Top Four After Clash End Goalless Against Man Utd

February 28, 2021

Job vacancy: Client Service Executive

December 15, 2019

Ololufe by Wally G Konkolo (Mp3 Download)

February 9, 2020
Nigerian Man Abroad Donates Family House To Christ Embassy, Renders Family Members Homeless

Nigerian Man Abroad Donates Family House To Christ Embassy, Renders Family Members Homeless

March 1, 2021
China Unveils Luxury Motorhome With A Second Storey And An Elevator (Photos)

China Unveils Luxury Motorhome With A Second Storey And An Elevator (Photos)

February 25, 2021
Fulani Kidnappers In Ondo Use Generators , Play Music Inside The Forest

Miyetti Allah Says Herdsmen Carrying Guns On Social Media Are Photoshopped

March 1, 2021
Obafemi Martins Reacts To CDQ & Burna Boy’s Drama

Obafemi Martins Reacts To CDQ & Burna Boy’s Drama

March 3, 2021
Martin Braithwaite Sends Barcelona To Copa Del Rey Final After Epic Comeback Against Sevilla

Martin Braithwaite Sends Barcelona To Copa Del Rey Final After Epic Comeback Against Sevilla

March 3, 2021
Presidency To Nigerians: Wear Your Masks Or Risk Fresh COVID-19 Lockdown

FG Extends Stay-at-home Directive For Workers

March 3, 2021
“We Will End Insurgency In 2021” – Buhari Promises

Buhari Directs Security Agents To Shoot Anyone Seen With AK-47

March 3, 2021
Boko Haram Frees Kidnapped Pastor Who Begged FG, CAN For Help

Boko Haram Frees Kidnapped Pastor Who Begged FG, CAN For Help

March 3, 2021
Governors To Meet Over COVID-19 Vaccines And Distribution

Governors To Meet Over COVID-19 Vaccines And Distribution

March 3, 2021
CDQ Blows Hot, Call Out Burna Boy And His Boys For Disrespecting Obafemi Martins

Rapper CDQ Stabbed By Burna Boy’s Squad Over Obafemi Martins Drama

March 3, 2021
Ondo Government Makes Compulsory Recitation Of Oodua Anthem In All Schools In The State

Ondo Government Makes Compulsory Recitation Of Oodua Anthem In All Schools In The State

March 3, 2021
Resident Raises Alarm As Disbanded SARS ‘Returns’ To Lagos Roads

Resident Raises Alarm As Disbanded SARS ‘Returns’ To Lagos Roads

March 3, 2021
Blockade: Meat Scarcity, High Food Prices Persist In Lagos, Ibadan, Others

Blockade: Meat Scarcity, High Food Prices Persist In Lagos, Ibadan, Others

March 3, 2021
Facebook Instagram Twitter Youtube

An online media website for latest news and updates in Technology, Business, Education, Sports, Politics, Entertainment, Health, Fashion...and many more.

About

  • Advertise
  • Contact
  • Newsletter

Quick Links

  • Privacy
  • Terms of Use
  • DMCA

Ideasgist © 2021 - Website designed by Ideasbeams.

No Result
View All Result
  • Home
  • Media
  • Education
    • School
    • Jamb
    • University
    • Polytechnic
    • College of Education
  • Technology
  • News
    • Politics
    • local
    • world
  • Sport
  • Entertainment
    • Media
  • Lifestyle
  • More Topics
    • Business
    • Banking
    • Telecom
    • Job

Ideasgist © 2021 - Website designed by Ideasbeams.

Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?