Fix WordPress Error Establishing a Database Connection

Fix WordPress Error Establishing a Database Connection – 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.

This issue can be caused by incorrect database information in your WordPress settings, a corrupt database, or an irresponsive database server.

WordPress needs the following information for connecting to the database:

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

Here are the steps to fix error establishing database connection issue in WordPress:

Check if the WordPress Database Credentials are correct:

Please make sure that you have the correct database credentials in your wp-config.php file:

Fix WordPress Error Establishing a Database Connection

Make sure that the MySQL database name and user exist:

Fix WordPress Error Establishing a Database Connection

Change the user password with the one from wp-config.php to make sure you have the same password:

Fix WordPress Error Establishing a Database Connection

Check if your Database has the correct host:

In some cases, the hosting provider keeps the databases host to some separated servers. So your database is not hosted on localhost. In this case, you have to contact your hosting company to make sure you have the correct IP address.

How to Repair a WordPress Database:

If you are facing different issues on your website like “One or more database tables are unavailable. The database may need to be repaired” you know that you need to repair it. How to do it? Simple:

Just add this code before “That’s all, stop editing! Happy blogging” line wp-config.php.

define('WP_ALLOW_REPAIR', true);

This will automatically create a repair file for your WordPress Database: http://www.example.com/wp-admin/maint/repair.php

Fix WordPress Error Establishing a Database Connection

And the last thing that worked for many WordPress users:

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

UPDATE wp_options SET option_value='YOUR_SITE_URL' WHERE option_name='siteurl'
Fix WordPress Error Establishing a Database Connection

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Related Posts

Leave a Reply

Your email address will not be published.