Problem Description
I am trying to setup moodle and running into a connection problem. See the config below:
<?php // Moodle configuration file
unset($CFG);
global $CFG;
$CFG = new stdClass();
$CFG->dbtype = 'mysqli';
$CFG->dblibrary = 'native';
$CFG->dbhost = 'localhost';
$CFG->dbname = 'gs_vle';
$CFG->dbuser = 'root';
$CFG->dbpass = 'root';
$CFG->prefix = 'mdl_';
$CFG->dboptions = array (
'dbpersist' => 0,
'dbport' => '',
'dbsocket' => '',
);
$CFG->wwwroot = 'http://localhost/~ryanme/work/vle/';
$CFG->dataroot = '/Users/ryanme/sites/work/moodledata';
$CFG->admin = 'admin';
$CFG->directorypermissions = 0777;
require_once(dirname(__FILE__) . '/lib/setup.php');
I am getting a database connection error.
See the error below:
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/2002): No such file or directory in /Users/ryanme/Sites/work/vle/lib/dml/mysqli_native_moodle_database.php on line 79
Things I have done
- Logged in with the root user via terminal and checked I can see the database with `show databases;`. This works fine.
- Checked the settings are correct over and over.
- Compared the config file to teams setup and it's pretty much the same.
- Ensured the mysqli module is enabled for PHP. It is.
What can I do to figure out what is causing this database connection error?
AI-Generated Solution
Powered by LMSouq AI · GPT-4.1-mini
Analyzing problem and generating solution…
Was this solution helpful?