一次mysql不能写入空值的奇怪处理结果

mysql版本 5.7.19

status 这个字段没有默认值,insert的时候也没有写一列,出错

#1364 - Field 'status' doesn't have a default value

要查看 /etc/my.cnf

[mysqld]
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
user=mysql


# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/usr/local/mysql/logs/mysqld.log
pid-file=/usr/local/mysql/data/mysqld.pid

sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

网上查,sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"   应该就是可以忽略空值的,但是怎么都不成功。

最后,把这一行调个位置就正常了,原因不明。

[mysqld]
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
user=mysql

sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/usr/local/mysql/logs/mysqld.log
pid-file=/usr/local/mysql/data/mysqld.pid

 

你可能感兴趣的:(服务器,msyql)