title: “Connection refused” error when connecting to local MySQL server?
body: <p>I am having this error:</p>
  <pre class="lang-none prettyprint-override"><code>Warning: mysql_connect(): [2002] Connection refused (trying to connect via tcp://127.0.0.1:3306)
  </code></pre>
  <p>I saw a similar question and I tried the solution by changing <code>localhost</code> to <code>127.0.0.1</code>, but it is still not working. I am using Mac OS X Lion. Please any help would be appreciated</p>
  <p>This is the PHP code I use to connect:</p>
  <pre class="lang-php prettyprint-override"><code>&lt;?php
      require(&quot;constants.php&quot;);
      // open database
      $connect = mysql_connect(DB_SERVER,DB_USER,DB_PASS) or die('error connecting: ' . mysql_error());
      // select database
      mysql_select_db(DB_NAME) or die('error selecting db: ' . mysql_error());
  ?&gt;
  </code></pre>