title: Reasons for MySQL authentication error: "Access denied for user 'xxx'@'yyy'"?
body: <p>What possible reasons could exist for MySQL giving the error <code>“Access denied for user 'xxx'@'yyy'”</code> when trying to access a database using PHP-mysqli and working fine when using the command-line mysql tool with exactly the same username, password, socket, database and host?<br>
  <strong>Update:</strong><br>
  There were indeed three users in the <code>mysql.user</code> table, each one with a different host (but with the same hashed password), one was set to localhost, one to 127.0.0.1 and one to the machine’s host name. Deleting two of them and changing the host of the third to “%” had only one effect: now the access is denied using the command-line tool also.
  I did do a</p>
  
  <pre><code> select user();
  </code></pre>
  
  <p>before that in the command line and it yielded the same xxx@yyy that were denied in php.</p>