title: MySQL + Django / ERROR 1045 and CommandError
body: <p>I configured MySQL as follows:</p>
  <pre class="lang-sql prettyprint-override"><code>CREATE DATABASE IF NOT EXISTS foodb;
  
  CREATE USER IF NOT EXISTS 'foo'@'localhost';
  ALTER USER 'foo'@'localhost' IDENTIFIED BY 'qux';
  GRANT ALL ON foodb.* to 'foo'@'localhost';
  SHOW GRANTS FOR 'foo'@'localhost';
  
  FLUSH PRIVILEGES;
  
  SELECT user, host, authentication_string FROM mysql.user ORDER BY user, host;
  </code></pre>
  <p>When I run</p>
  <pre class="lang-sh prettyprint-override"><code>python manage.py dbshell
  </code></pre>
  <p>I get the following error:</p>
  <pre><code>ERROR 1045 (28000): Access denied for user 'foo'@'localhost' (using password: YES)
  CommandError: &quot;mysql --user=foo --host=localhost foodb&quot; returned non-zero exit status 1.
  </code></pre>
  <p>Also, this query</p>
  <pre class="lang-sql prettyprint-override"><code>SHOW GRANTS for 'foo'@'localhost';
  </code></pre>
  <p>returns</p>
  <pre><code>+--------------------------------------------------------------+
  | Grants for foo@localhost                                     |
  +--------------------------------------------------------------+
  | GRANT USAGE ON *.* TO 'foo'@'localhost'                      |
  | GRANT ALL PRIVILEGES ON `foodb`.* TO 'foo'@'localhost'       |
  +--------------------------------------------------------------+
  2 rows in set (0.00 sec)
  </code></pre>
  <p>Finally, switching user to root and the root account password works just fine. So I think the issue must be with the user permissions on MySQL itself.</p>
  <p>What additional permissions does 'foo'@'localhost' need for this to work?</p>