Field 'id' doesn't have a default value 这个错误完美解决

时间:2022-09-19 23:35:12

1.Field 'id' doesn't have a default value

2.Field 'id' doesn't have a default value

程序启动的时候出现这个是因为一个非常幼稚的错误,认真观察自己的数据库有没有主键和自增加了没有!!!!!!!!!!!!!!!!!

本博主遇到这个问题的时候百度了一下

解决方法一:
打开my.ini,查找
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
修改为
sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
然后重启MYSQL
解决方法二:MySQL 5 uses a strict mode which needs to be disabled.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.
这些办法都是不行的,只有本博主的方法才有用,已自测通过。

如果有用请帮忙点个赞吧。。