Error Establishing a Database Connection in WordPress Stop your whole site and also site admin control. This error, the Website owner cannot use the website. If your site will offline then its gave bad effects to your users. This error message show when your WordPress site can’t unable to connect with the Database WordPress needs Database name, username, password, and server for connecting to the database. It is difficult to solve for beginner users. You can solve this fatal error with some methods.
“Error Establishing a Database Connection” issue can be caused by many reasons
- Your WordPress login details may have been changed.
- If you install any corrupt Plugins.
- Your Database is not able to connect with your WordPress.
- If Your Hosting does not work properly for some reason.
- D.B. Information is changed by mistake.
You can fix this error with some methods. Try all methods to solve these problems because every site has a different problem, Don’t know which method work to repair your site.
Check Database Login Credentials in wp-config
The most common reason for Error Establishing a Database Connection is incorrect database credentials. It mainly shown when you change your wordpress hosting server. You can check the wordpress database credentials in the wp-config.php file. This file contains important WordPress settings including D.B. information.
Find the wp-config.php file and check this file. Make sure Information on the database name, username, password, and host are correct. If PHP file information didn’t match with the D.B. then correct it. You can find database information in MySQL D.B. Its look like this-
/** MySQL database username */// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define( ‘DB_NAME’, ‘database_name’ );/** MySQL database username */
define( ‘DB_USER’, ‘username’ );/** MySQL database password */
define( ‘DB_PASSWORD’, ‘Password’ );/** MySQL hostname */
define( ‘DB_HOST’, ‘host_name’ );
Check Database Host Information
If you check login credentials and make sure those are correct and the problem is not resolved then you need to check Database host information. Most of the hosting companies use the localhost as your database host.
But some hosting companies do not use the localhost. If your hosting company didn’t use the localhost then you should contact your hosting service provider to confirm your database host information.
Repair Database
If your problem is not solved then you should use the 3rd method of Repairing WordPress Database. Your database needs repairing to work properly. You can repair your database by adding a code in your wp-config.php file.
define( ‘WP_ALLOW_REPAIR‘ , true);
Once you add this code in the file then search http://www.yoursite.com/wp-admin/maint/repair.php and then you can see the Repair Database option, and click on repair database.
After completing the repairing of the D.B., you should remove this code in the PHP file.
Check if the database server goes down
If you have done the above method and the problem is still shown then it means your database server is not working. It goes down when you have heavy traffic on your website then your hosting server didn’t handle this traffic. (especially when you use shared hosting).
If you have other sites on same hosting server then check that the website server goes down or not. You can also check your site in different browsers. If this is not worked then you can contact your hosting provider to resolve it.
Read also… Check what is Technical SEO, parts and its Importance