Friday, July 12, 2013

How turn on sql_mode to stric in mysql

1) Edit my.cnf
For Debian :
located at /etc/mysql/my.cnf , add to my.cnf
    [mysqld]
    sql_mode="STRICT_ALL_TABLES"
 If you want strict mode with full group by use this
[mysqld]
sql_mode="STRICT_ALL_TABLES,ONLY_FULL_GROUP_BY"

2) Restart mysql

3) Check it by running this query
SELECT @@GLOBAL.sql_mode;
Note: If you want turn off strict mode on run time just run this query
SET @@global.sql_mode='STRICT_ALL_TABLES'
OR
SET @@session.sql_mode='STRICT_ALL_TABLES'
Thats it.





No comments:

Post a Comment