Field 'id' doesn' t have a default value

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.