Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get rid of STRICT SQL mode in MySQL

Tags:

This is a follow up to this question MYSQL incorrect DATETIME format

How to get rid of STRICT_TRANS_TABLES once and for all?

mysql --help reports the following configs:

Default options are read from the following files in the given order: /etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf  $ ls  /etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf ls: /Users/pain/.my.cnf: No such file or directory ls: /etc/mysql/my.cnf: No such file or directory ls: /usr/local/etc/my.cnf: No such file or directory /etc/my.cnf  $ cat /etc/my.cnf [mysqld] sql_mode=NO_ENGINE_SUBSTITUTION 

But this doesn't help. I have some legacy code and each time I reboot the computer I have to launch mysql and change sql_mode.

Update

So I gave up on Homebrew-installed MySQL and downloaded it from from mysql.com. But that didn't help either. Following the answers here: How to fix `unknown variable 'sql-mode=ANSI'`? I have tried different variations of /etc/my.cnf: [mysql], [mysqld], sql_mode, sql-mode – nothing helped.

like image 858
firedev Avatar asked Sep 12 '13 10:09

firedev


People also ask

How do I change SQL mode in MySQL?

To change the SQL mode at runtime, set the global or session sql_mode system variable using a SET statement: SET GLOBAL sql_mode = 'modes'; SET SESSION sql_mode = 'modes'; Setting the GLOBAL variable requires the SUPER privilege and affects the operation of all clients that connect from that time on.

Why is MySQL strict mode?

Strict mode controls how MySQL handles invalid or missing values in data-change statements such as INSERT or UPDATE . A value can be invalid for several reasons. For example, it might have the wrong data type for the column, or it might be out of range.

How do I turn off InnoDB strict mode?

You can also enable or disable InnoDB strict mode at run time with the statement SET [GLOBAL|SESSION] innodb_strict_mode= mode , where mode is either ON or OFF . Changing the GLOBAL setting requires the SUPER privilege and affects the operation of all clients that subsequently connect.

How do I turn off strict mode in phpmyadmin?

You can change the value of sql_mode to NO_ENGINE_SUBSTITUTION to completely disable strict mode, but you may want to look up each mode that is configured before disabling it. If sql_mode isn't set, you can add it under the [mysqld] heading, then save the file, and restart MySQL.


1 Answers

This problem scuppered me for a while as well. None of the answers so far addressed the original problem but I believe mine does so I'll post it in case it helps anyone else.

I have MySQL (from mysql.com) Community Edition 5.7.10 installed on OS X 10.10.3

In the end I created a /etc/mysql/my.cnf with the following contents:-

[mysqld]  sql_mode=NO_ENGINE_SUBSTITUTION 

After restarting the server a SHOW VARIABLES LIKE 'sql_mode'; gave me:-

+---------------+------------------------+ | Variable_name | Value                  | +---------------+------------------------+ | sql_mode      | NO_ENGINE_SUBSTITUTION | +---------------+------------------------+ 1 row in set (0.00 sec) 

Finally, no strict mode!

like image 142
Paul Warren Avatar answered Sep 17 '22 13:09

Paul Warren