Django >python manage.py migrate报错:(1064, “You have an error in your SQL syntax
执行如下命令时报错(迁移数据库和表结构):
python manage.py makemigrations
python manage.py migrate
报错信息:
django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table ((1064, “You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘(6) NOT NULL)’ at line 1”))
环境信息:
python3.7 + Django2.2.4 +mysql 5.5.62
报错原因:
Django 2.1.x 以后要求MySQL 5.6或更高。它通过将DateTimeField映射到datetime(6)打破了兼容性,根本原因就是不兼容。
两种解决办法:
1、安装更高版本的Mysql数据库。
2、在settings.py文件最顶部增加如下代码:
from django.db.backends.mysql.base import DatabaseWrapper
DatabaseWrapper.data_types['DateTimeField'] = 'datetime' # fix for MySQL 5.5
重新执行数据库迁移命令。
参考文章:https://stackoverflow.com/questions/52730817/django-migrate-error-mysql-exceptions-programmingerror-1064-you-have-an-err
Django >python manage.py migrate报错:(1064, “You have an error in your SQL syntax相关推荐
- 执行python manage.py migrate报错问题解决
新人一枚,最近在学习django.在执行mysql同步的时候发生错误. The above exception was the direct cause of the following except ...
- 关于python manage.py migrate报错的解决方法
问题描述: Django .*需要MySQL 5.6或更高版本.它通过映射DateTimeField到打破了兼容性datetime(6). 在PyhCharm的命令行中执行python manage. ...
- 完美解决python manage.py makemigrations 报错
pycharm界面下面的Terminal里执行 1 python manage.py makemigrations app(你所创建的app名字) 2 python manage.py migrate ...
- 数据库报错:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server v
数据库出现 [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your M ...
- python manage.py runserver报错
在运行下面命令之后 python manage.py rserver 192.168.12.188:8001 预期的结果是这样的: 但是却报了这样的错误: 数据库密码不正确 解决: setting中的 ...
- 运行python manage.py runserver报错现象、原因和解决办法
出现这样的情况,是因为,数据库设置出了问题,修改manage.py中的数据库设置
- 【Django】执行python manage.py makemigrations报错的解决方案
我是一个甜甜的大橙子
- MraiaDb sql文件导入Mysql失败,报错:You have an error in your SQL syntax; check the manual that corresponds to
1,ENGINE = Aria 改为 MyISAM 2,ROW_FORMAT = Page 改为 ROW_FORMAT = Dynamic;
- centos7 mysql 1064_【mysql报错】1064 - You have an error in your SQL syntax;
mysql 报错1064 - You have an error in your SQL syntax;https://www.cndba.cn/debimeng/article/3198 数据库版本 ...
最新文章
- 流程快速开发平台,工作流引擎中间件,工作质量考核设计
- iphone XCode调试技巧之EXC_BAD_ACCESS中BUG解决
- 你朋友圈里的广告是怎么做到合你胃口的?
- Mina2.0框架源码剖析(八)
- java精确测量文本高度_Android精确测量文本宽高及基线位置的方法
- 按采用的传输介质计算机网络可分为4种,2015年4月全国自考计算机应用基础试卷及答案(00018)...
- Bourbon: 让你的sass更简洁
- java test circle_java-使用Jacoco和Circle CI生成测试覆盖率失败
- 订餐系统-第一个用NodeJs实现的项目
- 微型计算机基础知识提纲,自考“微型计算机应用基础”自考大纲(6)
- 如何重装win 10 系统
- 河北专升本经验总结分享
- Luogu3403: 跳楼机
- STM32MP157C-DK2 开机测试
- 如何快速搭建一个简单图像搜索引擎
- Python字串(string)基础与20种常见操作
- python 读excel中一个表_python 实现读取一个excel多个sheet表并合并的方法
- 下载谷歌play应用_选择在现有应用中使用Google Play应用签名
- 测试、发布、小组合作及经验启示
- CSS :hover选择器