While working with Joomla if you get an error – “Database Error: Unable to connect to the database:Could not connect to database”, check following properties in Joomla’s configuration.php file :
//given values are sample data only. var $dbtype = 'mysql'; var $host = 'localhost'; var $user = 'user_jo151'; var $password = 'YourPassword'; var $db = 'user_jo151'; var $dbprefix = 'jos_';
1. You should make sure you are using the correct MySQL username and database name in your configuration.php file. There should be no space before and after your username and password.
2. In addition, make sure that your MySQL username is added to your database. Sometimes MySQL username is not added to your database.
3. This issue can also be caused by errors within the database itself. So if all above properties are correct and you are still getting this error, in such a case you can try restoring your Joomla database.