Websites that are running with databases like WordPress, it is not impossible that you may encounter database error at some point. Here are the common reasons why you have this error:
- Incorrect database password
- Incorrect database username
- Incorrect database name
There are two ways you can fix this:
Follow the steps below on how to fix the error via cPanel:
Step 1. Log in to the cPanel using this link format: http://yourdomain.com/cpanel/
Replace yourdomain.com with the Main Domain Name connected to your hosting.
Step 2. Click File Manager under Files panel.
Step 3. Locate your WordPress directory. If this is under public_html, select wp-config.php file.
Step 4. Click on Edit on the menu bar
Or, right-click and choose Edit.
Step 5. Click Edit on the pop-up Edit box.
Step 6. On the editor page, locate the database name, username, and password.
Check if the database credentials and make sure they’re all correct. Modify the credentials if necessary.
Step 7. Click Save Changes on the top-right.
Follow the steps below on how to fix the error via FTP:
1. Open FTP application.
2. Locate WordPress directory. If this is under public_html, select wp-config.php and download.
3. Access the file via editor.
4. Locate the database name, username, and password.
5. Save the changes done on wp-config.php and upload it back to the directory.
You will need to override the existing wp-config file. From there, try accessing your website if there are any changes.