我正在通过这个资源学习Django(版本号为1.3.1)。链接是:http://www.djangobook.com/en/2.0/chapter05/
我通过Synaptic安装了"mysql-server"和"python-mysqldb"。我在settings.py文件中更改了相关设置。
上述书籍告诉我们可以在manage.py shell中运行以下命令:
>>> from django.db import connection
>>> cursor = connection.cursor()
运行这些命令后,我收到了以下错误:
OperationalError: (1044, "Access denied for user ''@'localhost' to database 'mydb'")
Traceback (most recent call last):
File "<console>", line 1, in <module>
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'")
MySQL在我第一次安装时要求我设置根密码,这个密码会被用在这里吗?还是还有其他的密码?
mydb
;",我会得到相同的错误。错误 1044 (42000):用户''@'localhost'对数据库'mydb'没有访问权限。 - user1265125