title: Warning: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock) in
body: <p>My code was working all fine yesterday and today it suddenly just don't want to connect to my database. I have changed no settings on it or on the code and I haven't updated any software either. All I do is this:</p>
  
  <pre class="lang-php prettyprint-override"><code>new PDO('mysql:host=localhost;port=3306;dbname=test', 'username', 'password');
  </code></pre>
  
  <p>And I get a nice exception message saying this:</p>
  
  <blockquote>
    <p>Warning: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock) in ...</p>
  </blockquote>
  
  <p>The thing is: I'm clearly not trying to connect using a unix socket but using TCP/IP. What am I doing wrong? Is there something I'm missing here?</p>
  
  <p>Thanks for any help.</p>