mysql不同版本 not null 处理方法 Column 'id' cannot be null

浏览:15115 发布日期:2015/12/01 分类:技术分享 关键字: mysql not null Column 'id' cannot be null
MySQL升级后,在执行sql语句
insert INTO `表名` ( ) VALUES ( );
时出现错误:
#1264 - Out of range value for column ‘’ at row 1
#1048 - Column 'id' cannot be null
原因:新版本的MySQL对字段的严格检查。(使用了auto_increment )

解决方法:
修改my.ini,将
sql-mode=”STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION”
改为
sql-mode=”NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION”。
重新启动MySQL。

Linux 下是改 /etc/my.cnf ,可能没有sql-mode,

可在[mysqld] 下加 sql-mode=”NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION”

用 mysql> SELECT @@sql_mode;查询当前模式
最佳答案
评论( 相关
后面还有条评论,点击查看>>