Related Services:
Situation :
Your live WordPress website starts showing you a database connection error.
Solution :
There could be several reasons behind this error. Basically, WordPress is not able to connect to server MySQL DB. Let's look into all the possible reasons and solutions for each possibility.
Before we move ahead, get the basic information of your WordPress database from wp-config.php. This can be found in the root directory of your WordPress installation. The default path in Cpanel is, typically /public_html/wp-config.php.
Once you open this file, navigate to the value called DB_NAME. The string of numbers or letters after it is the WordPress database name.
You can check other database details there as well by looking up the
, or
values since they all represent your WordPress database details.
- The database is deleted or not present:
The first thing you should do is to make sure the WordPress database is present.
Login to Cpanel from Netspace or direct Cpanel link: www.yourdomain.com/cpanel. If you forget your password you can Change Cpanel Password from Netspace Panel.
- Once logged in Cpanel, look for MySQL® Databases under the Database heading.
- You should be able to see your Database here. If not, then you may have deleted the DB or your DB is not local. Make sure to check if your DB_HOST is localhost or your server IP.
- If your database is present make sure Current Users under Cpanel is the same as DB_USER in wp-config.php and if the username is the same then try resetting the password from Cpanel >> MYSQL Database >> Current Users (Change Password) as per the wp-config.php
- Check If your WordPress website is now loading.
- Repair MYSQL Database:
If everything in step 1 is correct and then there could be a possibility that your database is corrupted.
Login into Cpanel >> MYSQL Database look for your WordPress database from your finding under wp-config.php
In front of your DB, there will be a database repair option (as shown in the screenshot)
Click on the repair database and try loading your website.
The above steps should be able to solve your error by establishing a database connection error. If you are still facing the issue then do contact our Hosting Support team.