Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    The Future of Google Search: AI Mode and Overviews

    May 21, 2025

    Deforestation and Its Impact: A Deep Dive into Environmental Consequences

    May 21, 2025

    Digital Detox and Mindful Tech Use: Reclaiming Balance in a Hyperconnected World

    May 21, 2025
    Facebook Twitter Instagram
    • Home
    • Features
      • Example Post
      • Typography
      • Contact
      • View All On Demos
    • Technology

      The Future of Google Search: AI Mode and Overviews

      May 21, 2025

      Smarter Robots with Gemini AI

      May 20, 2025

      💸 Google Pay: Making Payments Easy and Secure

      May 20, 2025

      AI vs. Teachers: How GPT is Changing the Role of Educators

      May 19, 2025

      Top 5 Best Programming Languages for AI in 2025

      May 19, 2025
    • Typography
    • Phones
      1. Technology
      2. Gaming
      3. Gadgets
      4. View All

      The Future of Google Search: AI Mode and Overviews

      May 21, 2025

      Smarter Robots with Gemini AI

      May 20, 2025

      💸 Google Pay: Making Payments Easy and Secure

      May 20, 2025

      AI vs. Teachers: How GPT is Changing the Role of Educators

      May 19, 2025

      The Metaverse: A New Frontier in Virtual Reality

      April 11, 2023

      Exploring the World of AR/VR Technology

      April 8, 2023

      Game Development tool : Unity

      January 10, 2023

      Game Development This Week: Save On Essential Tools and More

      November 19, 2022

      OpenAI’s Sora: A Glimpse into the Future of Video Creation?

      February 17, 2024

      Songs of Innovation: Write Music Like Never Before

      February 13, 2024

      LK99 Superconductor: A Complete Game-Changing Marvel

      August 15, 2023

      Redmi 12 5G Review: Fast, Affordable and Feature-Packed

      August 7, 2023

      Find Your Lost Android Phone: A Simple Guide

      December 29, 2023

      Instagram Ads: Run Your First Ad Campaign in Just 5 Easy Steps

      December 5, 2023

      The Most Radiation Emitting Phones of 2023 You Need To Know

      December 4, 2023

      Redmi 12 5G Review: Fast, Affordable and Feature-Packed

      August 7, 2023
    Facebook Twitter Instagram Pinterest Vimeo
    Zarsco Blogs🚀Zarsco Blogs🚀
    • Home
    • Features
      • Example Post
      • Typography
      • Contact
      • View All On Demos
    • Technology

      The Future of Google Search: AI Mode and Overviews

      May 21, 2025

      Smarter Robots with Gemini AI

      May 20, 2025

      💸 Google Pay: Making Payments Easy and Secure

      May 20, 2025

      AI vs. Teachers: How GPT is Changing the Role of Educators

      May 19, 2025

      Top 5 Best Programming Languages for AI in 2025

      May 19, 2025
    • Typography
    • Phones
      1. Technology
      2. Gaming
      3. Gadgets
      4. View All

      The Future of Google Search: AI Mode and Overviews

      May 21, 2025

      Smarter Robots with Gemini AI

      May 20, 2025

      💸 Google Pay: Making Payments Easy and Secure

      May 20, 2025

      AI vs. Teachers: How GPT is Changing the Role of Educators

      May 19, 2025

      The Metaverse: A New Frontier in Virtual Reality

      April 11, 2023

      Exploring the World of AR/VR Technology

      April 8, 2023

      Game Development tool : Unity

      January 10, 2023

      Game Development This Week: Save On Essential Tools and More

      November 19, 2022

      OpenAI’s Sora: A Glimpse into the Future of Video Creation?

      February 17, 2024

      Songs of Innovation: Write Music Like Never Before

      February 13, 2024

      LK99 Superconductor: A Complete Game-Changing Marvel

      August 15, 2023

      Redmi 12 5G Review: Fast, Affordable and Feature-Packed

      August 7, 2023

      Find Your Lost Android Phone: A Simple Guide

      December 29, 2023

      Instagram Ads: Run Your First Ad Campaign in Just 5 Easy Steps

      December 5, 2023

      The Most Radiation Emitting Phones of 2023 You Need To Know

      December 4, 2023

      Redmi 12 5G Review: Fast, Affordable and Feature-Packed

      August 7, 2023
    Subscribe
    Zarsco Blogs🚀Zarsco Blogs🚀
    Home » How to Fix the Error Establishing a Database Connection in WordPress
    Technology

    How to Fix the Error Establishing a Database Connection in WordPress

    mrzulfBy mrzulfFebruary 25, 2023Updated:February 25, 2023No Comments7 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
    Share
    Facebook Twitter LinkedIn Pinterest Email

    Are you seeing the ‘Error establishing a database connection’ notice on your WordPress website? It is a fatal error that makes your WordPress website inaccessible to the users.

    This error occurs when WordPress is unable to make a connection to the database. A number of things can affect your WordPress database connection which makes it a bit difficult for beginners to troubleshoot.

    In this article, we will show you how to easily fix the error establishing a database connection in WordPress.

    What Causes Error Establishing a Database Connection in WordPress?

    The ‘Error establishing a database connection’ issue can be caused by incorrect database information in your WordPress settings, corrupt database, or an irresponsive database server.

    Database connection error in WordPress

    A database is a software which makes it easy to store, organize, and retrieve data into other software.

    As a content management system, WordPress uses a database to store all your content and other website data. It then connects to the database each time someone visits your website.

    WordPress needs the following information for connecting to the database:

    • Database name
    • Database username
    • Database password
    • Database server

    This information is stored in your WordPress configuration file called wp-config.php.

    If any of these items are incorrect, WordPress would fail to connect to your database server, and you’ll see the ‘Error establishing a database connection’ error.

    It is one of the most common WordPress errors. Apart from incorrect credentials, this error can also appear if the database server is down, or the database files are corrupt.

    Let’s take a look at how to fix error establishing database connection issue in WordPress with step by step troubleshooting.

    1. Check Your WordPress Database Credentials

    The most common reason for database connection error in WordPress is incorrect database credentials. If you have recently moved your WordPress site to a new host, then this could be the most likely reason.

    Your WordPress database credentials are stored in the wp-config.php file. It is the WordPress configuration file that contains important WordPress settings including database information.

    If you have not edited wp-config.php file before, then take a look at our guide on how to edit wp-config.php file in WordPress.

    You’ll be looking for the following lines in the wp-config.php file.

    123456789// ** 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' );

    You need to make sure that the information for the database name, username, password, and database host is correct.

    You can confirm this information from your WordPress hosting account dashboard. Simply log in to your hosting account and click on MySQL databases under the database section.

    We’re using Bluehost dashboard in our screenshot, but the process will be similar in other hosting control panels.

    Database information

    This will take you to the database management page in your hosting dashboad. From here, you can find out your database name and the username.

    Database name and username

    Below that you will find the database users and links to change the user password.

    Changing database user password

    Once you have confirmed your database name, username, and password, you can change that information in your wp-config.php file if needed.

    After that, try visiting your website again to see if the database connection error has gone.

    If you can still see the error, then this means that something else is wrong. Continue reading for more troubleshooting steps.

    2. Check Your Database Host Information

    If you are confident that your database name, username, and password information is correct, then you may want to make sure that you are using the correct database host information.

    Most WordPress hosting companies use localhost as your database host. However, some managed WordPress hosting companies use separate servers to host databases. In that case, your database host information will not be localhost.

    You need to contact your WordPress hosting company to confirm your database host information.

    3. Repair WordPress Database

    If you are getting a different error on the wp-admin, for instance, something like “One or more database tables are unavailable. The database may need to be repaired”, then you need to repair your database.

    You can do this by adding the following line in your wp-config.php file. Make sure to add it just before ‘That’s all, stop editing! Happy blogging’ line wp-config.php.

    1define('WP_ALLOW_REPAIR', true);

    Once you have done that, you can see the settings by visiting this page: http://www.yoursite.com/wp-admin/maint/repair.php

    Repair WordPress database

    Note: the user does not need to be logged in to access the database repair page. Once you are done repairing and optimizing your database, make sure to remove this code from your wp-config.php.

    4. Check if Your Database Server is Down

    If everything seems to be correct, and WordPress still cannot connect to the database, then your database server (MySQL server) may be down.

    This could happen due to heavy traffic on a server. Basically, your host server just cannot handle the load (especially when you are on shared hosting).

    Your site will get really slow and for some users it may even output the error. So the best thing you should do is get on the phone or live chat with your hosting provider and ask them if your MySQL server is responsive.

    If you have other websites running on the same server, then you can check those sites to confirm that your SQL server is down.

    If you do not have any other site on the same hosting account, then simply go to your hosting dashboard and try to access 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:

    12345678<?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 connected successfully, then it means that your user has sufficient permission, and there is something else that is wrong.

    Go back to your wp-config file to make sure that everything there is correct (re-scan for typos).

    Other Solutions That Have Worked for Users

    If the above-mentioned troubleshooting tips failed to fix the database connection error on your website, then you may try these additional steps.

    Reported by our users, these steps have helped some users resolve the database connection error on their websites.

    1. Update WordPress Site URL

    Try updating the WordPress site URL using phpMyAdmin. Simply access phpMyAdmin from your hosting account dashboard, and select your WordPress database.

    Running SQL in phpMyAdmin

    After that click on the SQL menu on the top and enter the following MySQL query.

    1UPDATEwp_options SEToption_value='YOUR_SITE_URL'WHEREoption_name='siteurl'

    Don’t forget to provide your own site URL and change wp_options to your own table name as you may have changed the WordPress table prefix.

    2. Rebooting Web Server

    Users on dedicated servers, local server, and virtual private servers (VPS) can try rebooting their servers.

    This will restart your web and database server which may fix some temporary glitches causing the error.

    3. Ask for help

    If everything else fails, then you may need to contact your web hosting company. All good WordPress hosting companies will help you troubleshoot the problem, point you in the right direction, or even fix it for you.

    eror wordpres
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleHow to Install Google Analytics in WordPress for Beginners
    Next Article 12+ Things You MUST DO Before Changing WordPress Themes
    mrzulf
    • Website

    Related Posts

    Editor's Picks

    The Future of Google Search: AI Mode and Overviews

    May 21, 2025
    Featured

    Smarter Robots with Gemini AI

    May 20, 2025
    Information

    💸 Google Pay: Making Payments Easy and Secure

    May 20, 2025
    Add A Comment

    Leave A Reply Cancel Reply

    Demo
    Top Posts

    The Future of Artificial Intelligence: Trends and Predictions

    August 7, 2023133 Views

    Love: A Journey of Endless Emotions

    August 7, 2023106 Views

    Some important questions related to E-Commerce

    January 22, 202397 Views
    Stay In Touch
    • Facebook
    • YouTube
    • TikTok
    • WhatsApp
    • Twitter
    • Instagram
    Latest Reviews
    85
    Featured

    Pico 4 Review: Should You Actually Buy One Instead Of Quest 2?

    mrzulfJanuary 15, 2021
    8.1
    Uncategorized

    A Review of the Venus Optics Argus 18mm f/0.95 MFT APO Lens

    mrzulfJanuary 15, 2021
    8.9
    Editor's Picks

    DJI Avata Review: Immersive FPV Flying For Drone Enthusiasts

    mrzulfJanuary 15, 2021

    Subscribe to Updates

    Get the latest tech news from FooBar about tech, design and biz.

    Demo
    Most Popular

    The Future of Artificial Intelligence: Trends and Predictions

    August 7, 2023133 Views

    Love: A Journey of Endless Emotions

    August 7, 2023106 Views

    Some important questions related to E-Commerce

    January 22, 202397 Views
    Our Picks

    The Future of Google Search: AI Mode and Overviews

    May 21, 2025

    Deforestation and Its Impact: A Deep Dive into Environmental Consequences

    May 21, 2025

    Digital Detox and Mindful Tech Use: Reclaiming Balance in a Hyperconnected World

    May 21, 2025

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    Facebook Twitter Instagram Pinterest
    © 2025 Zasrco Blogs. Designed by Zarsco.

    Type above and press Enter to search. Press Esc to cancel.