The special reasons for the error "Unable to connect to the database: Could not connect to MySQL in Joomla" are list below. Please have a thorough look on the below list reasons and rectify your error according.
Please check that your database do exist. You can check the same from PhpMyAdmin.
The Mysql database name or username or password don't match with the configuration.php file database name or username or password.
Check the path of the database is correct or not. For example we give localhost and some other hosting provider give IP address as database path.
Note: The above errors may occurs due to various miscellaneous reason but just the most basic reasons are listed above.