执行如下命令时报错(迁移数据库和表结构):

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相关推荐

  1. 执行python manage.py migrate报错问题解决

    新人一枚,最近在学习django.在执行mysql同步的时候发生错误. The above exception was the direct cause of the following except ...

  2. 关于python manage.py migrate报错的解决方法

    问题描述: Django .*需要MySQL 5.6或更高版本.它通过映射DateTimeField到打破了兼容性datetime(6). 在PyhCharm的命令行中执行python manage. ...

  3. 完美解决python manage.py makemigrations 报错

    pycharm界面下面的Terminal里执行 1 python manage.py makemigrations app(你所创建的app名字) 2 python manage.py migrate ...

  4. 数据库报错: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 ...

  5. python manage.py runserver报错

    在运行下面命令之后 python manage.py rserver 192.168.12.188:8001 预期的结果是这样的: 但是却报了这样的错误: 数据库密码不正确 解决: setting中的 ...

  6. 运行python manage.py runserver报错现象、原因和解决办法

    出现这样的情况,是因为,数据库设置出了问题,修改manage.py中的数据库设置

  7. 【Django】执行python manage.py makemigrations报错的解决方案

    我是一个甜甜的大橙子

  8. 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;

  9. 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 数据库版本 ...

最新文章

  1. 流程快速开发平台,工作流引擎中间件,工作质量考核设计
  2. iphone XCode调试技巧之EXC_BAD_ACCESS中BUG解决
  3. 你朋友圈里的广告是怎么做到合你胃口的?
  4. Mina2.0框架源码剖析(八)
  5. java精确测量文本高度_Android精确测量文本宽高及基线位置的方法
  6. 按采用的传输介质计算机网络可分为4种,2015年4月全国自考计算机应用基础试卷及答案(00018)...
  7. Bourbon: 让你的sass更简洁
  8. java test circle_java-使用Jacoco和Circle CI生成测试覆盖率失败
  9. 订餐系统-第一个用NodeJs实现的项目
  10. 微型计算机基础知识提纲,自考“微型计算机应用基础”自考大纲(6)
  11. 如何重装win 10 系统
  12. 河北专升本经验总结分享
  13. Luogu3403: 跳楼机
  14. STM32MP157C-DK2 开机测试
  15. 如何快速搭建一个简单图像搜索引擎
  16. Python字串(string)基础与20种常见操作
  17. python 读excel中一个表_python 实现读取一个excel多个sheet表并合并的方法
  18. 下载谷歌play应用_选择在现有应用中使用Google Play应用签名
  19. 测试、发布、小组合作及经验启示
  20. CSS :hover选择器

热门文章

  1. python是c语言写的_python使用C语言写扩展示例
  2. vimplus国内源安装
  3. 蓝桥杯--试题 基础练习 数的读法
  4. 数据分析与数据挖掘的基础概念
  5. GISer转行送快递,如何寻个“风水宝地“?
  6. java防穿墙技术_Java贪吃蛇(穿身穿墙宝物)源码
  7. MySQL建立索引的注意事项
  8. 石头剪刀布python代码_Python之石头剪刀布小游戏(史上最详细步骤)
  9. 阜阳市历史悠久,人文蔚盛
  10. jBPM 工作流引擎可视化编辑器