SQL

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

끈끈 2023. 5. 29. 23:05

 

 

Django와 MySQL 사용중 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

 

 

https://docs.djangoproject.com/en/4.2/ref/databases/#mysql-sql-mode

 

Django

The web framework for perfectionists with deadlines.

docs.djangoproject.com

 

DATABASES = {
    'default' : {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': '', # 연동할 mysql db 이름
        'USER': '', # db 접속 계정명
        'PASSWORD': '', # 해당 계정 비밀번호
        'HOST': '',
        'PORT': '3306',
        'OPTIONS': {
            'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"
        }
    }
}

 

아래의 OPTIONS 부분을 추가해주면 해결~!

 

https://dev.mysql.com/doc/refman/8.0/en/server-options.html#option_mysqld_sql-mode

 

MySQL :: MySQL 8.0 Reference Manual :: 5.1.7 Server Command Options

5.1.7 Server Command Options When you start the mysqld server, you can specify program options using any of the methods described in Section 4.2.2, “Specifying Program Options”. The most common methods are to provide options in an option file or on t

dev.mysql.com