Warning: (3090, "Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated.

场景(一)

本人用peewee进行mysql语句报了一下错误(警告)

Warning: (3090, "Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. 
It will be removed in a future release.") result = self._query(query)

解决《一》(登录mysql执行命令)

set @@GLOBAL.sql_mode='';
set sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
set @@sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

解法《二》或者修改mysql文件下的(版本不同文件不同吧)

Warning: (3090,

在 [mysqld]和[mysql]下添加

sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

场景(二)

使用django出现这个问题

报错

/venv3.5/lib/python3.5/site-packages/pymysql/cursors.py:170: Warning: 
(3135, "'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' 
sql modes should be used with strict mode. 
They will be merged with strict mode in a future release.")
  result = self._query(query)

/venv3.5/lib/python3.5/site-packages/pymysql/cursors.py:170: Warning:
 (3090, "Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated.
  It will be removed in a future release.")
  result = self._query(query)

解决办法

DATABASES = {
     
  'default': {
     
        'ENGINE': 'django.db.backends.mysql',
        ...,
        'OPTIONS': {
     
            'init_command': "SET sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER'",
            'charset': 'utf8mb4'
         },
}

你可能感兴趣的:(数据库)