After you have restored your database, you might get any errors when trying to view your website. What would be those errors:
Error establishing a database connection
or
Warning: mysql_connect(): Access denied for user: 'user_name1@localhost' (Using password: YES) in /home/user123/public_html/catalog/includes/functions/database.php on line ##
Unable to connect to database server!
Such error means that your database exists in cPanel, but your web pages do not communicate properly with it. In this case you should assign a database username and reconfigure your website's database settings.
1. Login to your cPanel "Domain Owner Panel" and click the "MySQL Databases" icon.
2. Scroll down and find "MySQL Users > NewUser".
3. Type a username you want to use.
4. Pick a password and make it strong! You don't need to memorize it. This is another good reson to make it impossble to remember. Then copy the password, enter it twice and press the "Create User" button.
The user is now created, but it is still to be assigned to a database.
5. In the same screen, under "MySQL Users" you will find a section called "Add User To Database".
6. Choose the username you have just created from the drop down menu. cPanel will automatically prefix your database name with your cPanel username. For this example, we get "user2003_example". Copy your username and keep it ready.
7. Choose the name of your database and click the "Submit" button. If you do not know which database name to use, skip this step.
Now you have to locate your database configuration file.
- If you have a general error message like the first example and can not fix it, please respond to the "Hosting Account Restore"Â support ticket or create a new one.
- If you get a specific error message, like in the example below, then the error tells your exact line. In this example the error says "in /home/user2003/public_html/catalog/includes/functions/database.php on line ##".
7. Go to the configuration file and choose to Edit.
8. Browse the code and find the place where your database name is defined. An example:
define('DB_NAME', 'user_hcwp2');
define('DB_USER', 'user_name2');
define('DB_PASSWORD', 'hc2оfdGh$42н');
define('DB_HOST', 'localhost');
9. The database name is very important; it must have your new cPanel name in the first part. Update the part before the underscore, but change nothing after the underscore. Example:
define('DB_NAME', 'user2003_hcwp2');
If you skipped "Step 9" described above, while assigning the user to the database, you have to go back and complete this step. The value you have for your database name is the correct name to choose in the second drop down. (Don't forget to click Submit.)
10. Get the database "Username" and "Password" you have kept aside and replace those in the file. Example:
define('DB_USER', 'joe123_gatorboy');
define('DB_PASSWORD', 'nvGHdCC0dCMz');
You do not need to these "Username" and "Password" anymore, so do not bother to save them.
11. Your host name is always 'localhost', so please make this change.
12. Save the file and the job is done! Please now refresh your site page(s) on the web browser to see they work fine.
Â