What is MySQL strict mode?

MySQL strict mode controls the invalid or missing data when changes in queries are handled. When this mode is enabled, the invalid or missing data may cause warnings or errors when attempting to process the query. When this mode is disabled, the same query would have its missing or invalid values gets adjusted and would produce a simple warning.

How to disable MySQL strict mode?

The MySQL strict mode can be disabled by two steps. First, backup the files on the server before modifying it. To make backup, login to SSH with root user and give the command

cp -a/usr/my.cnf{,.strict.bak}

This command uses ‘BASH base expansion’ to make a backup copy of the file in the original directory.

Then edit the file by using your favorite command line operator. In the below example, ‘vim’ is used.

vim /usr/my.cnf

After performing this, a command line will appear inside the file as sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

At the end, MySQL strict mode will be disabled after restarting the MySQL service.

Categorized in: