我使用的是windows64it,mysql5.6.17,python2.7,mysqldb,django1.8.11。
当我提取django-1.8.11.tar.gz时,错误 - '无法创建符号链接...' - 发生。我忽略了这些错误。
我开始了一个新的django项目并更改了DATABASES'默认'与我的数据库连接设置匹配的项目:
'默认':{ ' ENGINE':' django.db.backends.mysql', ' NAME':' first', '用户':' yy', ' PASSWORD':' 123456', }
之后,我运行命令:python manage.py migrate
ERROR!
C:\Users\zhijie\mysite>python manage.py migrate
Operations to perform:
Synchronize unmigrated apps: staticfiles, messages
Apply all migrations: admin, contenttypes, auth, sessions
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
Rendering model states... DONE
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying sessions.0001_initial...Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "D:\python\lib\site-packages\django-1.8.11-py2.7.egg\django\core\manageme
nt\__init__.py", line 354, in execute_from_command_line
utility.execute()
File "D:\python\lib\site-packages\django-1.8.11-py2.7.egg\django\core\manageme
nt\__init__.py", line 346, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "D:\python\lib\site-packages\django-1.8.11-py2.7.egg\django\core\manageme
nt\base.py", line 394, in run_from_argv
self.execute(*args, **cmd_options)
File "D:\python\lib\site-packages\django-1.8.11-py2.7.egg\django\core\manageme
nt\base.py", line 445, in execute
output = self.handle(*args, **options)
File "D:\python\lib\site-packages\django-1.8.11-py2.7.egg\django\core\manageme
nt\commands\migrate.py", line 222, in handle
executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
File "D:\python\lib\site-packages\django-1.8.11-py2.7.egg\django\db\migrations
\executor.py", line 110, in migrate
self.apply_migration(states[migration], migration, fake=fake, fake_initial=f
ake_initial)
File "D:\python\lib\site-packages\django-1.8.11-py2.7.egg\django\db\migrations
\executor.py", line 148, in apply_migration
state = migration.apply(state, schema_editor)
File "D:\python\lib\site-packages\django-1.8.11-py2.7.egg\django\db\backends\b
ase\schema.py", line 91, in __exit__
self.execute(sql)
File "D:\python\lib\site-packages\django-1.8.11-py2.7.egg\django\db\backends\b
ase\schema.py", line 111, in execute
cursor.execute(sql, params)
File "D:\python\lib\site-packages\django-1.8.11-py2.7.egg\django\db\backends\u
tils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "D:\python\lib\site-packages\django-1.8.11-py2.7.egg\django\db\backends\u
tils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "D:\python\lib\site-packages\django-1.8.11-py2.7.egg\django\db\utils.py",
line 98, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "D:\python\lib\site-packages\django-1.8.11-py2.7.egg\django\db\backends\u
tils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "D:\python\lib\site-packages\django-1.8.11-py2.7.egg\django\db\backends\m
ysql\base.py", line 124, in execute
return self.cursor.execute(query, args)
File "D:\python\lib\site-packages\MySQLdb\cursors.py", line 174, in execute
self.errorhandler(self, exc, value)
File "D:\python\lib\site-packages\MySQLdb\connections.py", line 36, in default
errorhandler
raise errorclass, errorvalue
django.db.utils.OperationalError: (1142, "INDEX command denied to user 'yy'@'loc
alhost' for table 'django_session'")
答案 0 :(得分:0)
您的数据库用户没有必要的访问权限。错误消息
"INDEX command denied to user 'yy'@'localhost' for table 'django_session'"
表示这一点。
对于开发,您可能希望使用此语句添加完整访问权限
GRANT ALL PRIVILEGES ON first.* TO 'yy'@'localhost' IDENTIFIED BY '123456';