Django使用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 m
anual that corresponds to your MySQL server version for the right syntax to use near '(6) NOT NULL)' at line 1"))

查看了博客是版本不兼容,用cmd进行版本查看:

MySQL为mysql -u用户名 -p密码

python为输入python或直接输入python --version

Django为进入python后输入>>> import django
>>> django.get_version()

我的Django是2.1,python是3.7,MySQL是5.5

https://blog.csdn.net/qq_36963372/article/details/82558085 此文描述需要升级MySQL至少到5.6

进入mysql后使用 show variables like "%char%" 来查看mysql位置(或者输入select @@basedir as basePath from dual)

接着用此博客方法进行更新: https://www.cnblogs.com/xkfeng/p/7860124.html

安装mysql记得配置环境变量哦,如:

使用MySQL创建create database 相对应PyCharm项目APP数据库名字

回到PyCharm,打开terminal,输入python manage.py makemigrations:

输入python manage.py migrate:

成功!

代码创建:

mysql查看创建结构:

猜你喜欢

转载自blog.csdn.net/zoukai1587/article/details/88706700