title: Mac OS X 10.8 MySQL connection error: localhost does not work, 127.0.0.1 all OK
body: <p>I have now a new MabBook with 10.8 and I am trying to set up all the Apache &amp; MySQL etc.
  Apache successfully runs including vhosts.</p>
  
  <p>In my /etc/hosts I have all the local hosts set including 127.0.0.1 localhost etc.</p>
  
  <p>When I try to coennct to one of my local vhost, e.g. alpensonne, I can connect to MySQL without any troubles. If I try to have the MySQL host to be localhost, I get the follwoing error:</p>
  
  <pre><code>Database connection error (2): Could not connect to MySQL.
  </code></pre>
  
  <p>I know the error (2) means username or password incorrect, but they are fine.
  If I connect with</p>
  
  <pre><code>mysql -u root
  SELECT password,host FROM user where user='root';
  </code></pre>
  
  <p>Also I have just done to be double sure:</p>
  
  <pre><code>SET PASSWORD FOR 'root'@'localhost' = '';
  </code></pre>
  
  <p>Is it possible that localhost uses a different MySQL socket? Maybe it then tries to connect to a different MySQL?</p>