General developer forum

Error: Database connection failed

 
Picture of vijay kumar
Error: Database connection failed
 

Hi

I am getting this error how to resolve this.

error

 
Average of ratings: -
Picture of Deepak Gour
Re: Error: Database connection failed
 

Hi Vijay,

I look like database connectivity problem.  

Go to your config.php. and check your credentials if it's correct. 

Also, try to login to MySQL using console with the same credentials and check if it works.

 
Average of ratings: -
Picture of Visvanath Ratnaweera
Re: Error: Database connection failed
Particularly helpful Moodlers
Here is a sample "screen shot":
$ cd /path/to/moodle 
$ grep CFG-\>db config.php
$CFG->dbtype = 'mysqli';
$CFG->dblibrary = 'native';
$CFG->dbhost = 'localhost';
$CFG->dbname = 'dbname';
$CFG->dbuser = 'dbuser';
$CFG->dbpass = 'dbpass';
$CFG->dboptions = array (
$ mysql -udbuser -pdbpass dbname
Welcome to the MySQL monitor. ...

 
Average of ratings: -
Picture of Rahul Rai
Re: Error: Database connection failed
 

Hi Vijay 

Check the database credential in config.php.

 
Average of ratings: -