Sign in
  • About Us
  • Featured Articles
  • Contributors’ Articles
  • TV Show
    • About
    • TV Episodes
  • Radio Show
    • About
      • Find a Station
      • Kevin Price: Host of the Price of Business Show
    • Radio Episodes
  • Listen
Sign in
Welcome!Log into your account
Forgot your password?
Password recovery
Recover your password
Search
Price of Business
  • About Us
  • Featured Articles
  • Contributors’ Articles
  • TV Show
    • About
    • TV Episodes
  • Radio Show
    • About
      • Find a Station
      • Kevin Price: Host of the Price of Business Show
    • Radio Episodes
  • Listen
Home Contributors' Articles How to Fix Error Establishing a Database Connection in WordPress?
  • Contributors' Articles

How to Fix Error Establishing a Database Connection in WordPress?

By
Price of Business News
-
February 22, 2018
0
Facebook
Twitter
Pinterest
WhatsApp

    If you come across the message, “error establishing database connection” when loading your WordPress website, there could be several underlying causes. Some of the different reasons include a crashed database due to low memory, incorrect database login details, or errors with the database tables. There are even more reasons why this error can be caused.

    The database is at the core of any WordPress site. MySQL stores all the key information related to your site. So whenever someone visits your site, a request is sent to the MySQL database to furnish the required information. The information is then presented on the visitor’s browser. But if there is any problem during this connection, it can result in the ‘error establishing a database connection’ message.

    This guide helps you fix this error based on the underlying cause.

    Common Causes

    Some of the common causes of the ‘error establishing a database connection’ message in WP include the following:

    • Incorrect Database Login Info: This can be caused due to typo mistakes, additional spaces, or incorrect quotes. When changes are made to the login details, it can block your WordPress site from getting access to the database.
    • Corrupt WP Database: Issues like poorly developed plugins, themes, and add-ons can corrupt your database. Even interruptions during data transfer can cause the error.
    • Server Unavailable: The error can also occur when the server housing your data has any issues. It can become unavailable due to several reasons including high traffic surge.

    q

    So how can you fix this WordPress error? If you are having the error message due to the above-mentioned reasons, you should be able to address it using the following steps.

    WordPress Site & Database Backup

    Make sure to start by taking backup up your WordPress site and database. In fact, it is important that you take WP backups on a regular basis. If this error has been caused by a database corruption, it is also likely that there may be some errors in the database. Before you begin the below-mentioned steps, make sure a fresh backup is maintained separately.

    1. Incorrect Database Login Details

    The database connection details are saved on the server in the file wp-config.php. when you move your WP install between different hosts or servers, it may be required to update these details.

    • Search for the wp-config.php file in the WordPress root directory
    • Open this file

    a

    • Check the following information in the file to ensure that they are correct as per your records:
      • define(‘DB_NAME’, ‘database_name’);
      • define(‘DB_USER’, ‘database_username’);
      • define(‘DB_PASSWORD’, ‘database_password’);
    • if you notice any incorrect information, make the changes and save the file.
    • You will be required to furnish a password
    • Run the following command while adding the right details from the config file: mysqlshow -u database_username –p
    • Enter the password and if you get the message ‘access denied error’, it means that the username/password are incorrect
    • If the username/password are correct, you will get an output
    • Check the output to ensure that one database matches with your WP config file

    If it matches, it means that there the ‘error establishing a database connection’ has not been caused due to an incorrect wp-config.php file. You can find more detailed information on this error in this 000Webhost blog post.

    2. Corrupt Database

    The next step is to ascertain whether the WordPress error has been caused due to corrupt database.

    • Open wp-admin
    • Open yoursite.com

    If both these attempts result in the ‘error establishing a database connection’, it means that there may be no issues with the database. However, if you do come across this error, you should check the database for errors. It is quite simple to fix a corrupt WP database.

    Locate the file, wp-config.php from the root directory using the following steps

    • Log into your cPanel
    • Access the File Manager
    • Open WordPress root folder

    The wp-config.php file is located in this folder.

    • Open the file in ‘editing’ mode
    • Right click on the file and click on ‘code editor’
    • Add this code to the bottom of the file: define ( ‘WP_ALLOW_REPAIR’ , true);
    • Click on save and close the file

    This code lets you to repair the WP database without the need for logging manually into phpMyAdmin.

    • Open the following: yoursite.com/wp-admin/maint/repair.php
    • Click on ‘repair database’ or ‘repair and optimize database’

    An automatic process will take place on the screen to fix the WordPress database.

    3. Server Unavailable

    If you tried the above-mentioned steps and are still facing the error establishing a database connection in WordPress, the issue could be linked with the host server. If you think this is the underlying cause, you should get in contact with your host. It may be because the server resources are unable to handle the surge in traffic, if you are using a shared hosting service.

    A quality web host will take the appropriate steps to ensure that uptime doesn’t get affected. If the host is unable to fix the problem, you should consider moving over to some other host.

    If the error establishing a database connection is caused due to traffic surges, you can take some alternative steps too. Install a high quality caching plugin. It should help save pages and posts as static files, thus reducing the stress on the server. However, if the issue is caused from the host side, you should let them find and fix it.

    Conclusion

    You can also fix the error establishing a database connection in WordPress error by restoring your site from a backup. For more details on the steps involved in this process, it is recommended to check this amazing blog post on 000Webhost. As already mentioned, all WordPress site owners should take regular backups of their website and database. This will keep you safe in case of any kind of error. This database connection error may sound to be something complicated, but you can fix it by following the above-mentioned simple steps. And it doesn’t take you more than a few minutes to address it.

    • TAGS
    • Database
    • Login
    • WordPress
    Facebook
    Twitter
    Pinterest
    WhatsApp
      Price of Business News

      RELATED ARTICLESMORE FROM AUTHOR

      Contributors' Articles

      The Neuroscience of Hypnotherapy in Coaching

      Contributors' Articles

      Embracing the Enlightened Workplace

      Contributors' Articles

      Will AI Change the Upcoming Elections?

      Markets

      About the Price of Business show

      LISTEN TO THE SHOW 24/7 on broadcast markets coast to coast and dozens of streaming platforms including iHeartRadio, Apple Podcasts, TuneIn  and many others.

      The Host of the Price of Business — Kevin Price — is Known for Getting the Big Interviews. New York Times Bestselling Authors, Multi-Billionaires, National Media Personalities, and more….

      This is the home of ReadInstead.com, which offers our favorite stories from our network and elsewhere. Subscribe to our free newsletter here.

      Find Kevin Price at Muck Rack

      Now you can ask Alexa to play the show for you, simply say “Alexa, ask AnyPod to play the Price of Business show.”

      The Price of Business Show is Distributed by USA Business Radio

      Check Out Some of the Prominent Newsmakers on the Price of Business Program

      Special Recent Posts

      How Small Businesses Can Compete With Large Ones

      September 20, 2023

      National News Former White House Advisor Explains Why Economic Freedom Works

      September 19, 2023

      Unmanned Surface Vehicles Become Oldest and Newest Fad in Warfare

      September 18, 2023

      Post Reporter on the Implications of UAW Strike

      September 18, 2023

      Empowering Your Clients To Retire on the Home

      September 18, 2023

      About Us

      Welcome to the Price of Business, which is one of the longest-running business shows in the country. Hosted by award-winning broadcast journalist, Kevin Price, this program brings fresh perspectives to national and business news.

      For information on sponsored posts, advertising, or our content in general, email articles@usabusinessradio.net.
      For other inquiries email BMuyco@usabusinessradio.net.

      GDPR INFORMATION

      This site does not collect your data. We do not resell your data. To avoid the possibility of such, we ask you to email us directly at the email above to avoid any issues of involuntary data accumulation on this site.

      EDITOR

      Kevin Price
      Kevin Price is the host of the nationally syndicated Price of Business show. It is one of the longest running shows of its kind in the country. He is also an author of several books, editor on several sites, and an award winning journalist.

      No articles on this site should be construed as the opinion of PriceofBusiness.com . Do your homework, get expert advice before following the advice on this or any other site.

      Price of Business News 2
      No articles on this site should be construed as the opinion of PriceofBusiness.com. Do your homework, get expert advice before following the advice on this or any other site.

      Important Links

      • About Us
      • Contributors
      • Kevin Price: Host of the Price of Business Show
      • Price of Business Audio Segments
      • Radio Show
      • TV Episodes
      • TV Show
      • What’s New?
      • Soundcloud
      • Employee Blogs

      Categories

      • Login
      • Log Out
      Copyright © 2023 The Price of Business. All Rights Reserved. Website Design and Developed By Mr Web Smith
      Follow via Facebook Follow via Linkedin Follow via Twitter Follow via Youtube Follow via Google Mail to