본문 바로가기
Django

MySQL Strict Mode is not set for database connection 'default' - django

by zgabriel 2024. 7. 3.
728x90

python manage.py migrate 실행 시 아래와 같은 오류가 발생한다면

WARNINGS:?: (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/4.2/ref/databases/#mysql-sql-mode

settings.py의 database 설정에 아래 옵션을 추가해주면 된다.

'default': {

'ENGINE': 'django.db.backends.mysql',

'NAME': 'test',

'USER' : 'test',

'PASSWORD' : 'test',

'DEFAULT-CHARACTER-SET' : 'utf8',

'HOST' : '127.0.0.1',

'OPTIONS': {

'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"

}

}

 

 

반응형