Quick Fix for Error Establishing Database Connection in WordPress

How to fix Error Establishing Database Connection in WordPress?
Facebook
Twitter
LinkedIn
WhatsApp
Email
Pinterest
Print

When WordPress cannot connect to the database, an error message titled “Error Establishing Database Connection in WordPress” will show up and is one of the most common WordPress errors. This could be caused by a number of things, including incorrect database login information, a shaky web host, or a problem with the database server itself.

How to fix Error Establishing Database Connection in WordPress?

To fix this error, you can try the following steps:

  1. Make sure the database login information in your wp-config.php file is accurate. You must access the file via FTP or your hosting control panel to verify the database login information in your wp-config.php file.Search for the following lines of code in the wp-config.php file after accessing it:

    define(‘DB_NAME’, ‘database_name_here’);
    define(‘DB_USER’, ‘username_here’);
    define(‘DB_PASSWORD’, ‘password_here’);
    define(‘DB_HOST’, ‘localhost’);

    The DB NAME, DB USER, and DB PASSWORD variables must be accurate and correspond to the database name, username, and password you use to access your database. Update any wrong values and save the modifications to the wp-config.php file.

    You can ask your web host for advice if you’re unsure of what the right values should be. They ought to be able to give you the proper database login information.

  2. To verify that the database server is functioning properly, speak with your site host.
  3. If the problem continues, try adding the next piece of code to your wp-config.php file to fix the database:define(‘WP_ALLOW_REPAIR’, true);

    This will enable you to access “http://yourdomain.com/wp-admin/maint/repair.php” and run the WordPress database repair tool. Be sure to remove that line once your issue is resolved.

  4. You might need to restore your website from a backup if none of the methods above are successful.

In conclusion, although there are a number of potential causes for the Error Establishing Database Connection in WordPress, it is typically brought on by faulty database login information, a shaky web host, or a problem with the database server. You should be able to fix this problem and get your website back up and running by following the above-listed instructions. Hope this helps.

Related Posts

About The Author

Dr. Sabbir is a  front-end software engineer and WordPress expert with over 12 years of experience in the tech industry. Although he received his medical degree from Rajshahi Medical University, Dr. Sabbir decided to focus on his passion for technology and website development full-time.

In his role as a front-end software engineer, Dr. Sabbir has helped design and develop user-friendly websites and applications for clients in various industries, including healthcare. He is well-versed in a variety of programming languages and is always looking for new ways to improve the user experience.

55K+ Members

Join Our Facebook Group

53k+ Followers

Follow Our Facebook Page