How To Turn off MySQL Strict Mode


By default, MySQL is enabled with strict_mode ON, which will most likely cause problems with older PHP applications written for MySQL 4.   For example, strict mode will return an error on insert statements if an empty string is provided where an integer is expected.

You may disable strict mode in one of two ways:

Open your “my.ini” file within the MySQL installation directory, and look for the text “sql-mode”.
Find:

# Set the SQL mode to strict
sql-mode=”STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION”

and change to

# Set the SQL mode to strict
sql-mode=”NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION”

or you can run the following on your database

SET @@global.sql_mode= ”;

Leave a comment

Your email address will not be published. Required fields are marked *