mysql 关闭strict模式

背景:公司使用的mysql 5.1 因为业务需要使用mysql 5.7(没有用之前的配置)
使用过程中报错说 “不支持text字段有默认值”, 我一直怀疑是mysql版本的原因, 搜索了一下报错后。知道了原来是strict导致的。

Strict Mode功能说明

不支持对not null字段插入null值
不支持对自增长字段插入”值
不支持text字段有默认值

关闭:

To disable strict SQL mode, SSH in to your server as root and create this file:

/etc/mysql/conf.d/disable_strict_mode.cnf

Open the file and enter these two lines:

[mysqld]
sql_mode=IGNORE_SPACE,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

你可能感兴趣的:(mysql)