django1.8 python manage.py syncdb 同步数据库时报错

zrcker 发布于 2015/12/10 13:57
阅读 2K+
收藏 0

如题,Mac os 10.10, Django1.8 在数据库同步的时候 python manage.py syncdb 出现了错误:

Ranger:mysite ranger$ python manage.py syncdb

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/commands/syncdb.py:24: RemovedInDjango19Warning: The syncdb command will be removed in Django 1.9

  warnings.warn("The syncdb command will be removed in Django 1.9", RemovedInDjango19Warning)

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...Traceback (most recent call last):

  File "manage.py", line 10, in <module>

    execute_from_command_line(sys.argv)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line

    utility.execute()

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute

    self.fetch_command(subcommand).run_from_argv(self.argv)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv

    self.execute(*args, **cmd_options)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute

    output = self.handle(*args, **options)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 25, in handle

    call_command("migrate", **options)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 120, in call_command

    return command.execute(*args, **defaults)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute

    output = self.handle(*args, **options)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 221, in handle

    executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/migrations/executor.py", line 110, in migrate

    self.apply_migration(states[migration], migration, fake=fake, fake_initial=fake_initial)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/migrations/executor.py", line 147, in apply_migration

    state = migration.apply(state, schema_editor)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 87, in __exit__

    self.execute(sql)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 107, in execute

    cursor.execute(sql, params)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute

    return super(CursorDebugWrapper, self).execute(sql, params)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute

    return self.cursor.execute(sql, params)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", line 97, in __exit__

    six.reraise(dj_exc_type, dj_exc_value, traceback)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute

    return self.cursor.execute(sql, params)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 124, in execute

    return self.cursor.execute(query, args)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute

    self.errorhandler(self, exc, value)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler

    raise errorclass, errorvalue

django.db.utils.OperationalError: (1142, "REFERENCES command denied to user 'zrck'@'localhost' for table 'django_content_type'")

求指教。初学python 第一个小项目,卡住过不去了~~~~

加载中
0
雪梨苹果
雪梨苹果

同步命令是

python manage.py makemigrations
python manage.py migrate

zrcker
zrcker
执行python manage.py makemigrations会返回No changes detected 执行python manage.py migrate还是会报和题目中同样的错误
0
zrcker
zrcker
自己回来答复下,其实就是用户权限的问题,切成root下 是可以顺利执行的,所以是mysql的用户权限设置没有起作用 , 用户‘zrck’没有执行操作的权限。
返回顶部
顶部