title: Using MySQL with Django - Access denied for user '@'localhost
body: <p>So I'm learning Django (1, 3, 1, 'final', 0) through this resource: <a href="http://www.djangobook.com/en/2.0/chapter05/" rel="noreferrer">http://www.djangobook.com/en/2.0/chapter05/</a></p>
  
  <p>I installed 'mysql-server' and 'python-mysqldb' via Synaptic. I changed the relevant setting in settings.py.</p>
  
  <p>The book mentioned above tells us to run from the manage.py shell:</p>
  
  <pre><code>&gt;&gt;&gt; from django.db import connection
  &gt;&gt;&gt; cursor = connection.cursor()
  </code></pre>
  
  <p>I get this error after running these commands:</p>
  
  <pre><code>OperationalError: (1044, "Access denied for user ''@'localhost' to database 'mydb'")
  
    Traceback (most recent call last):
    File "&lt;console&gt;", line 1, in &lt;module&gt;
    File "/usr/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 250, in cursor
      cursor = self.make_debug_cursor(self._cursor())
    File "/usr/lib/python2.7/dist-packages/django/db/backends/mysql/base.py", line 322, in _cursor
      self.connection = Database.connect(**kwargs)
    File "/usr/lib/python2.7/dist-packages/MySQLdb/__init__.py", line 81, in Connect
      return Connection(*args, **kwargs)
    File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 187, in __init__
      super(Connection, self).__init__(*args, **kwargs2)
  OperationalError: (1044, "Access denied for user ''@'localhost' to database 'mydb'")
  </code></pre>
  
  <p>MySQL did ask me to set a root password when I installed it the first time, would that be utilized here? or is it something else? </p>