gpt4 book ai didi

python - Django MySQL : MigrationSchemaMissing Error Windows

转载 作者:行者123 更新时间:2023-11-29 15:47:32 25 4
gpt4 key购买 nike

SO对此错误有很多疑问,但我无法摆脱它。我正在尝试将 Django 应用程序连接到 MySQL 数据库,但不断收到此错误:

 raise MigrationSchemaMissing("Unable to create the django_migrations table (%s)" % exc)
django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table ((1064, "pa
rse sql 'CREATE TABLE `django_migrations` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `app` varchar(255)
NOT NULL, `name` varchar(255) NOT NULL, `applied` datetime(6) NOT NULL)' error: syntax error at position 8 near
create"))

我已经初始化了一个新项目,并将 settings.py 更改为:

DATABASES = {
'default': {

'ENGINE': 'django.db.backends.mysql',
'NAME': 'some name',
'HOST': 'some ip',
'PORT': '3306',
# 'USER': '',
# 'PASSWORD': '',
'OPTIONS': {
# 'sql_mode': 'traditional',
'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
},
}
}

我已经删除了选项,但它不起作用。我使用了不同的 Django 版本和 mySqlClient 版本,但仍然无法使其工作。

我当前的Django和mysqlclient是最新版本,即mysqlclient-1.4.2.post1和django-2.2.3。

最佳答案

您的 MySQL 用户可能没有创建数据库的权限。

您可以通过在 MySQL 控制台上运行以下命令来修复此问题:

grant usage on schema public to username;
grant create on schema public to username;

关于python - Django MySQL : MigrationSchemaMissing Error Windows,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56952567/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com