title: Connect MySQL Using PDO
body: <p>I'm using the following string to connect to mysql database on a localhost ( I do not have root access). I DID read related posts on Stack Overflow. </p>
  
  <p>I defined this the php file:</p>
  
  <pre><code>ini_set('mysqli.default_socket', '/tmp/mysql5.sock');
  ini_set('mysql.default_socket', '/tmp/mysql5.sock');
  ini_set('pdo_mysql.default_socket', '/tmp/mysql5.sock');
  </code></pre>
  
  <p>When I use: </p>
  
  <pre><code>'mysql:localhost:/tmp/mysql5.sock;dbname='.DB_NAME.';charset=utf8'
  </code></pre>
  
  <p>or </p>
  
  <pre><code>'mysql:unix_socket:/tmp/mysql5.sock;dbname='.DB_NAME.';'
  </code></pre>
  
  <p>I got this</p>
  
  <blockquote>
    <p>SQLSTATE[HY000] [2002] No such file or directory</p>
  </blockquote>
  
  <p>When I use: </p>
  
  <pre><code>'mysql:host=127.0.0.1;dbname='.DB_NAME.';'
  </code></pre>
  
  <p>I got this</p>
  
  <blockquote>
    <p>SQLSTATE[HY000] [2002] Connection refused</p>
  </blockquote>
  
  <p>Anyone can take a look, thanks so much!!</p>