MySQL之Field‘***’doesn’t have a default value错误解决办法

首先排查一下数据库中对应的字段是否是设置为不能为空,以至数据插入不进去。个人就是这个缘由解决的。sql

下面,整理一下网上的相同问题的其余解决办法,方便出现问题的同窗参考:数据库

一、打开my.ini,查找this

sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"spa

修改成.net

sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"rest

而后重启MYSQLorm

二、MySQL 5 uses a strict mode which needs to be disabled.htm

In Windows, Goto Start-->Programs-->MySQL->MySQL Instance Config Wizard. Follow through the Reconfigure Instance option-->Detailed Configuration-->Continue Next a few screens. At the bottom under Enable TCP/IP option there is 'Enable Strict Mode'. Deslect this option (no tick). Save changes and MySQL will restart.it

三、看看你的数据库定义的时候是否是把主键生成方式设置为int的,可是没有设置为自增的!!或者数据定义的时候设置一个默认值就能够了。io

ps:

http://www.jb51.net/article/63554.htm

相关文章
相关标签/搜索