django:ySQL Strict Mode is not set for database connection 'default'
Posted 沧海一粟,何以久远
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了django:ySQL Strict Mode is not set for database connection 'default'相关的知识,希望对你有一定的参考价值。
?: (mysql.W002) MySQL Strict Mode is not set for database connection ‘default‘
HINT: MySQL‘s Strict Mode fixes many data integrity problems in MySQL, such as data truncation upon insertion, by escalating warnings into errors. It is strongly recommended you activate it. See: https://docs.djangoproject.com/en/2.1/ref/databases/#mysql-sql-mode
增加黄色配件的配置:
DATABASES = {
‘default‘: {
# ‘ENGINE‘: ‘django.db.backends.sqlite3‘,
# ‘NAME‘: os.path.join(BASE_DIR, ‘db.sqlite3‘),
‘ENGINE‘: ‘django.db.backends.mysql‘,
‘NAME‘: ‘erebus‘,
‘USER‘: ‘root‘,
‘PASSWORD‘: ‘root‘,
‘HOST‘: ‘127.0.0.1‘,
‘PORT‘: ‘3306‘,
‘OPTIONS‘: {
"init_command": "SET sql_mode=‘STRICT_TRANS_TABLES‘",
}
}
}
参考:https://www.jianshu.com/p/bc41a8bf9d9b
以上是关于django:ySQL Strict Mode is not set for database connection 'default'的主要内容,如果未能解决你的问题,请参考以下文章
MySQL技巧--SQL MODE(Strict SQL Mode)
MySQL Strict Mode is not set for database connection 'default'