title: Moodle database connection error
body: <p>I am trying to setup moodle and running into a connection problem. See the config below:</p>
  
  <pre><code>&lt;?php  // Moodle configuration file
  
  unset($CFG);
  global $CFG;
  $CFG = new stdClass();
  
  $CFG-&gt;dbtype    = 'mysqli';
  $CFG-&gt;dblibrary = 'native';
  $CFG-&gt;dbhost    = 'localhost';
  $CFG-&gt;dbname    = 'gs_vle';
  $CFG-&gt;dbuser    = 'root';
  $CFG-&gt;dbpass    = 'root';
  $CFG-&gt;prefix    = 'mdl_';
  $CFG-&gt;dboptions = array (
   'dbpersist' =&gt; 0,
   'dbport' =&gt; '',
   'dbsocket' =&gt; '',
  );
  
  $CFG-&gt;wwwroot   = 'http://localhost/~ryanme/work/vle/';
  $CFG-&gt;dataroot  = '/Users/ryanme/sites/work/moodledata';
  $CFG-&gt;admin     = 'admin';
  
  $CFG-&gt;directorypermissions = 0777;
  
  require_once(dirname(__FILE__) . '/lib/setup.php');
  </code></pre>
  
  <p>I am getting a database connection error.
  See the error below:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>Things I have done</p>
  
  <ul>
  <li>Logged in with the root user via terminal and checked I can see the database with <code>show databases;</code>. This works fine.</li>
  <li>Checked the settings are correct over and over.</li>
  <li>Compared the config file to teams setup and it's pretty much the same.</li>
  <li>Ensured the mysqli module is enabled for PHP. It is.</li>
  </ul>
  
  <p>What can I do to figure out what is causing this database connection error?</p>