Go to: http://blog.csdn.net/q283595518/article/details/4122053
Field 'id' doesn' t have a default value encountered a problem during project creation last night, during the test of data storage, the field 'id' doesn' t have a default value is always reported to be abnormal. I have been searching for it online for a long time. I have also tested it for a long time according to the statements of prawns, but I did not find the cause. I spent two or three hours, and finally found the problem: it turned out that when I designed the data, I defined the primary key type as Int, I originally wanted to use auto-increment, but due to my carelessness, I did not add auto_increment when writing SQL statements, so I always reported field information during data storage.
'Id' doesn' t have a default value. The ID has no value at all !!
In addition, the reasons for these problems are described by other people looking for them on the Internet:
1. Open My. ini and find
SQL-mode = "strict_trans_tables, no_auto_create_user, no_engine_substitution"
Change
SQL-mode = "no_auto_create_user, no_engine_substitution"
Restart MySQL
2. 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.
3. Check whether the primary key generation method is set to int when your database is defined, but it is not set to auto-increment !! Or set a default value for data definition.