A lot of integrated PHP environment (Phpnow WAMP Appserv, etc.) from the MySQL does not seem to open MySQL strict mode, what is the strict model of MySQL, in simple terms is the MySQL itself on the data for strict calibration (format, length, type, etc.), such as an integer field we write a string type of data, in the strict mode of MySQL does not complain, also if the definition of char or varchar type of field, when the written or updated data exceeds the defined length is not an error.
I don't think this is any good for programming, although we try to do data validation in our code. MySQL opened the strict mode from a certain program is a test of our code, if our development environment does not open strict mode in the development process has not encountered errors, then on the line or code porting will be possible to appear incompatible situation, So in the development process do the best to open MySQL strict mode.
How do I turn it on?
1. Can be opened by executing an SQL statement, but only valid for the current connection, the following is an SQL statement:
Copy Code code as follows:
Set sql_mode= "Strict_trans_tables,no_auto_create_user,no_engine_substitution";
2. By modifying the MySQL configuration file, look for Sql-mode in the configuration file and modify this line to:
Copy Code code as follows:
Sql-mode= "Strict_trans_tables,no_auto_create_user,no_engine_substitution"
If you don't find sql-mode=, you can add it under [mysqld] and recommend the second method, once and for all.