您现在的位置是: 网站首页> 学习笔记> Django Django
django在执行migrate时抛异常:django.db.utils.OperationalError: (1824, "Failed to open the referenced table 'auth_group'")
2024-07-06 [python] [django] 1659人已围观
如题,新建的项目,因为修改了,在做数据库迁移时抛如下异常:
> python .\manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions, tenants
Running migrations:
Applying contenttypes.0001_initial... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0001_initial... 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 auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying auth.0009_alter_user_last_name_max_length... OK
Applying auth.0010_alter_group_name_max_length... OK
Applying auth.0011_update_proxy_permissions... OK
Applying auth.0012_alter_user_first_name_max_length... OK
Applying tenants.0001_initial...Traceback (most recent call last):
File "D:\pyvenv\orderingsystems\lib\site-packages\django\db\backends\utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
File "D:\pyvenv\orderingsystems\lib\site-packages\django\db\backends\mysql\base.py", line 75, in execute
return self.cursor.execute(query, args)
File "D:\pyvenv\orderingsystems\lib\site-packages\MySQLdb\cursors.py", line 179, in execute
res = self._query(mogrified_query)
File "D:\pyvenv\orderingsystems\lib\site-packages\MySQLdb\cursors.py", line 330, in _query
db.query(q)
File "D:\pyvenv\orderingsystems\lib\site-packages\MySQLdb\connections.py", line 261, in query
_mysql.connection.query(self, query)
MySQLdb.OperationalError: (1824, "Failed to open the referenced table 'auth_group'")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\codes\orderingsystems\manage.py", line 22, in <module>
main()
File "D:\codes\orderingsystems\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "D:\pyvenv\orderingsystems\lib\site-packages\django\core\management\__init__.py", line 442, in execute_from_command_line
utility.execute()
File "D:\pyvenv\orderingsystems\lib\site-packages\django\core\management\__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "D:\pyvenv\orderingsystems\lib\site-packages\django\core\management\base.py", line 412, in run_from_argv
self.execute(*args, **cmd_options)
File "D:\pyvenv\orderingsystems\lib\site-packages\django\core\management\base.py", line 458, in execute
output = self.handle(*args, **options)
File "D:\pyvenv\orderingsystems\lib\site-packages\django\core\management\base.py", line 106, in wrapper
res = handle_func(*args, **kwargs)
File "D:\pyvenv\orderingsystems\lib\site-packages\django\core\management\commands\migrate.py", line 356, in handle
post_migrate_state = executor.migrate(
File "D:\pyvenv\orderingsystems\lib\site-packages\django\db\migrations\executor.py", line 135, in migrate
state = self._migrate_all_forwards(
File "D:\pyvenv\orderingsystems\lib\site-packages\django\db\migrations\executor.py", line 167, in _migrate_all_forwards
state = self.apply_migration(
File "D:\pyvenv\orderingsystems\lib\site-packages\django\db\migrations\executor.py", line 249, in apply_migration
with self.connection.schema_editor(
File "D:\pyvenv\orderingsystems\lib\site-packages\django\db\backends\base\schema.py", line 166, in __exit__
self.execute(sql)
File "D:\pyvenv\orderingsystems\lib\site-packages\django\db\backends\base\schema.py", line 201, in execute
cursor.execute(sql, params)
File "D:\pyvenv\orderingsystems\lib\site-packages\django\db\backends\utils.py", line 102, in execute
return super().execute(sql, params)
File "D:\pyvenv\orderingsystems\lib\site-packages\django\db\backends\utils.py", line 67, in execute
return self._execute_with_wrappers(
File "D:\pyvenv\orderingsystems\lib\site-packages\django\db\backends\utils.py", line 80, in _execute_with_wrappers
return executor(sql, params, many, context)
File "D:\pyvenv\orderingsystems\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
with self.db.wrap_database_errors:
File "D:\pyvenv\orderingsystems\lib\site-packages\django\db\backends\mysql\base.py", line 75, in execute
return self.cursor.execute(query, args)
File "D:\pyvenv\orderingsystems\lib\site-packages\MySQLdb\cursors.py", line 179, in execute
res = self._query(mogrified_query)
File "D:\pyvenv\orderingsystems\lib\site-packages\MySQLdb\cursors.py", line 330, in _query
db.query(q)
File "D:\pyvenv\orderingsystems\lib\site-packages\MySQLdb\connections.py", line 261, in query
_mysql.connection.query(self, query)
django.db.utils.OperationalError: (1824, "Failed to open the referenced table 'auth_group'")
目前使用的解决方法:
在数据库中执行以下命令可解决:
set GLOBAL foreign_key_checks=0;
相关文章
- django在执行migrate时抛异常:django.db.utils.OperationalError: (1824, "Failed to open the referenced table 'auth_group'")
- django接入支付宝支付抛异常request sign failed. int() argument must be a string, a bytes-like object or a real number, not 'Sequence'
- django使用自定义存储类上传图片到阿里OSS,makemigrations时报异常
- django admin使用自定义用户类以后,新增用户保存的密码为明文
文章评论
暂无评论添加评论
点击排行
本栏推荐
标签云
热评文章
- django使用qq邮箱发送邮件
- mysql8设置数据库远程连接
- pip修改下载源为国内源
- win10看不到win7共享的文件夹的解决方法
- SQLyog连接 Mysql 8.0.11 报error no.1251- Client does not support authentic...
- 使用Oracel Net Nanager配置Oracle数据库远程访问
- 将anaconda的下载源切换为国内的源
- Python+selenium+firefox设置代理IP
- selenium+firefox+js实现动态设置firefox浏览器代理IP
- scrapy文件下载(高新技术企业认定网)
- Python调用JS代码
- Chrome浏览器的overrides的使用
站点信息
- 建站时间:2021-01-01
- 网站程序:Django 3.1.2
- 文章统计:54篇
- 文章评论:37条
- 统计数据: