title: moodle - database connection failed when running a script
body: <p>So I am setting up a moodle plugin that syncs groups defined in child courses into a meta course. I managed to install it based on the following instruction.</p>
  <blockquote>
  <p>Installation</p>
  <p>Copy the metagroups folder into your Moodle /local directory and visit
  your Admin Notification page to complete the installation.</p>
  <p>After installation you may need to synchronize existing meta-course groups, to do this run the cli/sync.php script (use the --help switch for further instructions on script usage).</p>
  </blockquote>
  <p>So when i tried to run th sync.php script using this command in there terminal</p>
  <pre><code>php -f sync.php
  </code></pre>
  <p>it shows me an error message</p>
  <p><img src="https://i.stack.imgur.com/ZQjEk.png" alt="enter image description here" /></p>
  <p>I found that the line in the script that is causing this issue is the following line</p>
  <blockquote>
  <p>require_once(<strong>DIR</strong> . '/../../../config.php');</p>
  </blockquote>
  <p>my config.php file looks like this:</p>
  <p><img src="https://i.stack.imgur.com/zXmAE.png" alt="enter image description here" /></p>
  <p>I have no idea why this is happening, as all moodle functionality seems to be working, which means database connection is the way it should be. Does anyone know this is happening and a way around this. Thanks in advance.</p>
  <p>By the way, my moodle version is 2.6.3 running in localhost on a mac OSX 10.9</p>