Strict mysql Mode

Source: Internet
Author: User

Strict mode in mysql many integrated PHP environments (such as PHPnow WAMP Appserv) do not seem to have enabled the strict mode of MySQL. What is the strict mode of MySQL, simply put, MySQL strictly checks the data (format, length, type, and so on). For example, for an integer field, we write data of the string type, in non-strict mode, MySQL does not report errors. If a char or varchar field is defined, no error is reported if the written or updated data exceeds the defined length. I think this is no good for programming, although we try to do data validation in the code. MySQL has enabled the strict mode. In a certain program, it is a test of our code. If the strict mode is not enabled in our development environment, there is no error during the development process, therefore, incompatibility may occur during online or code porting. Therefore, it is best to enable the MySQL strict mode during the development process. How to enable it? 1. You can enable it by executing an SQL statement, but it is only valid for the current connection. The following is an SQL statement:

Set SQL _mode = "STRICT_TRANS_TABLES, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION ";

 

2. Modify the MySQL configuration file, search for SQL-mode in the configuration file, and change this line:
SQL-mode = "STRICT_TRANS_TABLES, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION"

 

If SQL-mode = cannot be found, add it to [mysqld]. The second method is recommended.

Related Article

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.