How to Fix the Error Establishing a Database Connection?

by | Last Updated Feb 24, 2021 | WordPress | 0 comments

The Error Establishing a Database Connection warning on your WordPress website is a fatal error.

This error causes your WordPress website unavailable to your website visitors.

When WordPress is unable to establish a connection to the database, this error happens.

Many things can affect your WordPress database connection, making it a bit hard for beginners to troubleshoot.

This article can learn how to fix the Error Establishing a Database Connection in WordPress quickly.

Why Do You See Error Establishing a Database Connection in WordPress?

Incorrect database information in your WordPress settings causes the Error Establishing a Database Connection.

Error Establishing a Database Connection in WordPress

A corrupt database or an unresponsive database server also throws this error.

What is a Database?

A database is software that makes it easy to store, organize, and retrieve data into other software.WordPress utilizes a database to store all your content and other data.

Every time someone visits your website, WordPress connects to the database.

For connecting to the database, WordPress requires the following information.

  • Database Name
  • Database Username
  • Database Password
  • Database Server

WordPress stores this information in the wp-config.php file. This wp-config.php file is the WordPress configuration file.

WordPress will fail to connect to your database server if any of these values are incorrect.

With this step-by-step troubleshooting, let us see how to fix the Error Establishing a Database Connection issue in WordPress.

Verify Your WordPress Database Credentials

Wrong database credentials are the usual reason for database connection errors in WordPress.

Have you migrated your WordPress site to a new host recently? Then this could be the most likely reason.

The wp-config.php file saves your WordPress database credentials.

This WordPress configuration file holds critical WordPress settings.

To check the values in the wp-config.php file, log in to the DirectAdmin control panel.

File Manager DirectAdmin

Click on the File Manager under System Info & Files section.

Now open the public_html folder.

Edit File DirectAdmin

Mouse hover on wp-config.php and click on the Edit File.

Take a look at the following lines in your wp-config.php file.

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’ );

It would be best to make sure that the Database Name, Database Username, Database Password, and Database Server are correct.

You can verify this information from your DirectAdmin dashboard.

MySQL Management DirectAdmin

Log in to your DirectAdmin account and click on MySQL Management under the Account Manager section.

Database List DirectAdmin

You can now see the MySQL Management page with all the Databases listed.

From here, click on the database name associated with your WordPress website.

Database Users DirectAdmin

On the Users page, you can take various actions to your database.

  • Create New User
  • Add Existing User
  • Delete User
  • Change Password
  • Modify Privileges

Change WordPress Database Password

If you are unsure about the database password or wish to update it, click on the Change Password link.

Database Change Password DirectAdmin

In this CHANGE PASSWORD pop-up, you can Generate Random Password or input a password.

You can toggle hide and show on clicking the eye icon.

You can copy the password to your clipboard as well.

Now click on the Change button, and the database password will update.

Have you confirmed your database name, username, and password? You can now modify that information in your wp-config.php file if needed.

Now try revisiting your website to see if the database connection error has gone.

Do you still see the error? Then that means something else is incorrect.

Contact Support

All great WordPress hosting companies can support you in troubleshooting the problem. Or point you in the correct direction to fix it yourself.

Have you hosted your WordPress website with us?

Then create a support ticket, and we are happy to fix it for you.

If you enjoyed this tutorial, then you’ll love Rovity and our fast-growing premium shared hosting on the cloud. Check our subscription plans.

We engineered our cloud infrastructure with Performance, Speed, Scalability, and Security in mind.

That’s why we built Rovity with AWS, CloudLinux OS, DirectAdmin, and LiteSpeed Web Server.

Come and experience the next generation of shared hosting on the cloud

By Gifty Antony

Gifty is passionate about Web Development and connected with various communities. She loves WordPress.

Check Out These Related Posts

Avoid These 8 Blogging Mistakes in 2021

Avoid These 8 Blogging Mistakes in 2021

Blogging plays a large part in the $400 billion content marketing industry. Blogs are an excellent way to make substantial extra income. They're also powerful tools for generating traffic to your website. Blogging isn't just a part-time gig and a digital marketing...

read more
How to Add HTTP Security Headers in WordPress

How to Add HTTP Security Headers in WordPress

Would you like to add HTTP security headers to your WordPress website? With HTTP security headers, your WordPress website will have an extra layer of protection. This will prevent malicious activity from affecting your website performance. The tutorial below will walk...

read more

0 Comments

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *