所以我正在通过这个资源学习 Django (1, 3, 1, 'final', 0):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第一次安装时确实要求我设置root密码,这里可以使用吗?或者是别的什么?