关于Django 2.1执行migrate报错:django.db.migrations.exceptions.MigrationSchemaMissing

使用Python3.6 + Django2.1 + MySQL 5.5 在执行(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"))

 万恶的兼容问题出现了。

之前在执行:python manage.py makemigrations     时一切正常。

可见问题是出在了MySQL上。于是乎,仔细的查看了Django的发行说明:

终于找到了这么一句,心中狠狠的来了句问候。

然鹅,我还想抢救一下,(重装是很麻烦很麻烦的...)。

。。。大量的时间过去,终于找到这么一句:

datetime(6) NOT NULL

 好了。找到报错的那句SQL语句了。MySQL5.5并不支持datetime(6)这种语法,没补救的想法了,赶紧重装MySQL吧。

顺便说一句:

Python社区推荐学习Python3.6+ ,Python的组件也会慢慢地往高版本迁移。所以,大家尽量使用最新版吧,要不然遇到了莫名其妙的兼容性问题,来来回回地折腾真的很让人抓狂。我想没人会愿意学习BB机修理吧。

猜你喜欢

转载自blog.csdn.net/qq_36963372/article/details/82558085