WordPress error establishing-database connection

Troubleshooting the WordPress “Error Establishing Database Connection”

Encountering the “Error Establishing Database Connection” message on your WordPress website can be frustrating. This error indicates that your site is unable to connect to the database, often resulting from changes in database authorization settings. In this blog post, we will explore how to resolve this issue and get your website back up and running smoothly.

Have you ever encountered the dreaded “Error Establishing Database Connection” while working on your WordPress website? Don’t panic! Let’s dive into some simple steps to troubleshoot and resolve this error.

Step 1: Verify the wp-config.php file

The first place to look for a solution is the “wp-config.php” file. This file holds important credentials related to your WordPress database. Check if the file is there in your public_html or htdocs folder. If so, check if the information mentioned in the file is correct, including the database name, username, password, and host. Make sure to save any changes you make to the file.

Here’s a snippet of the code you should look for in the “wp-config.php” file:

phpCopy code/** The name of the database for WordPress */
define( 'DB_NAME', 'database_name' );
/** MySQL database username */
define( 'DB_USER', 'username_here' );
/** MySQL database password */
define( 'DB_PASSWORD', 'password_here' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' );

To confirm these details, access your hosting account settings and navigate to the database management section. Cross-check the information with what is mentioned in the “wp-config.php” file. Keep in mind, you will not find the database password in plain sight, but you can always renew it for any database user. Also, check that the database user is assigned to the database and has full permissions.

Step 2: Repairing database tables

In some cases, you might encounter additional errors, such as missing database tables, when accessing the wp-admin area. To tackle this issue, you can add a specific code snippet to the “wp-config.php” file.

Add the following line before the final line of the file:

phpCopy codedefine('WP_ALLOW_REPAIR', true);

Once you’ve added the code, access the following URL by replacing “yourdomain.com” with your actual domain name: https://yourdomain.com/wp-admin/maint/repair.php. This link will take you to the WordPress database repair tool, allowing you to repair and optimize your database tables effortlessly.


The “Error Establishing Database Connection” in WordPress can be a frustrating roadblock, but with the right steps, you can quickly resolve it. By verifying the database credentials in the “wp-config.php” file and potentially repairing the database tables, you can overcome this issue and get your website back online.

Remember, it’s crucial to double-check the accuracy of the information in the “wp-config.php” file and ensure its alignment with your hosting account settings. Following these steps will help you restore the connection between your WordPress site and its database, providing a seamless browsing experience for your visitors.

So, the next time you encounter the “Error Establishing Database Connection” in WordPress, don’t fret. Arm yourself with these troubleshooting steps, and you’ll have your website up and running smoothly in no time! Otherwise contact us for help. That’s what we do daily.

Related Posts

what social networks to use

What Social Networks Should You Use for Your Business?

Having a strong online presence is essential for any business. But with so many social networks available, it can be overwhelming to decide where to focus your efforts. To make the most of your online marketing strategy, it’s crucial to understand the unique characteristics of each social network and tailor your content accordingly. In this […]

different direction for better website performance

The Ultimate Guide to Speeding Up Your Website

Slow Website? Have you ever been on a website that seems to take ages to load? It’s frustrating, right? Well, the good news is that you can make your own website super speedy with just a bit of know-how. Whether you’re using WordPress or another platform, we’re here to guide you through the process step […]