In order to troubleshoot a database connection error, first you must check the database name and password.
- Log into cPanel.
- Navigate to MySQL Databases menu.
- Check whether a database and a username exists.
- If your website is based on WordPress, open the wp-config.php file. The database and username have to defined within the config file.
- If you're not sure the password is correct or not, you can reset it through the MySQL Database menu and save it within the config file.
- Save the wp-config.php file and refresh the website to check.