xamppmoodle

Database error during moodle installation


I am installing moodle on xampp server and it gives me this error

Error: Database connection failed
It is possible that the database is overloaded or otherwise not running properly.
The site administrator should also check that the database details have been 
correctly specified in config.php

Warning: mysqli::mysqli(): (HY000/1045): Access denied for 
user 'admin'@'localhost' (using password: YES) in 
C:\xampp\htdocs\moodle\lib\dml\mysqli_native_moodle_database.php on line 77.

I am new to moodle and tried my best to solve this but I am unable to solve it. Need some help.


Solution

  • Do you have something like this in your config.php

    $CFG->dbtype    = 'mysqli';
    $CFG->dblibrary = 'native';
    $CFG->prefix    = 'mdl_';
    $CFG->dboptions = array (
      'dbpersist' => 0,
      'dbsocket' => 0,
    );
    
    $CFG->dbhost    = 'localhost';
    $CFG->dbuser    = 'yourdbusername';
    $CFG->dbpass    = 'yourdbuserpassword';
    $CFG->dbname    = 'yourdbname';
    

    If you do then check if you can access the database. If you have phpmyadmin installed, then try to login as dbuser and dbpass and see if you can see the dbname.

    If you don't have the config or the database then the easiest way to create a database is to go into phpmyadmin, go to the users tab, add user then enter the user details and select "Create database with same name and grant all privileges" so the database and the user name are the same. Then copy those details into your config.php