Receiving a 'Cannot Connect to Database' error indicates that the database settings entered in the configuration files are somehow incorrect. Here are a few things you may want to confirm:
Does the database exist, and is is spelled correctly?
Does the database user exist?
Is the database user assigned to the database?
Is the password in the settings the current password for the database user?
So long as these basic settings are in place and correct, this should resolve a 'Cannot Connect to Database' error.
For further information:
Please refer to the cPanel documentation for database features, here: https://documentation.cpanel.net/display/68Docs/MySQL+Databases