Mysql-1364 Error

Source: Internet
Author: User
From: http://hi.baidu.com/eason_fun/blog/item/f2844a99af3258066e068c86.html

 

Recently, PHP + MySQL has been used in new projects. N has never touched these two things for a long time, and the result is quite a problem. For a database insert operation, the echo SQL is directly copied to MySQL manager for execution. Worked ~ However, if the insert operation is not executed on the page, mysql_error () is output, which is a 1364 error. The result is as follows:

MySQL 1364 error message: #1364-field "details" doesn' t have a default value.

Generally, the details field does not have a default value. That is to say, we did not assign a value to it, and the default value is not set for this field in the table.
This is something that was developed after mysql5. take a closer look at this section in the my. ini file:Code# Set the SQL mode to strict # SQL-mode = "strict_trans_tables, no_auto_create_user, no_engine_substitution" SQL-mode = "strict_trans_tables, no_auto_create_user, no_engine_substitution"

If you cannot see my. ini, You can execute the following SQL command. SQL code select @ Global. SQL _mode;

You may suddenly notice: strict_trans_tables (the storage engine enables strict mode and the invalid data value is denied ). This is why 1364 is returned when data is inserted: The default value is not set for the details field.

There are two solutions:
First, set the default value for fields that may not have data during database design.
Second: Set the SQL mode. There are two methods:

(1) Configure My. INI, remove: strict_trans_tables to restart MySQL service my. ini configuration code # Set the SQL mode to strict # SQL-mode = "strict_trans_tables, no_auto_create_user, no_engine_substitution" SQL-mode = "no_auto_create_user, no_engine_substitution"

(2), run the SQL command. Note: This Command requires permissions! SQL code set @ Global. SQL _mode = "no_auto_create_user, no_engine_substitution";

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.