Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn on/off MySQL strict mode in localhost (xampp)?

I want to know how to check whether MySQL strict mode is on or off in localhost(xampp).

If on then for what modes and how to off.

If off then how to on.

I already followed http://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sql-mode-full and https://mariadb.com/kb/en/mariadb/sql_mode/ and other related sites too. But I didn't get an exact answer for my question.

like image 525
Ipsita Rout Avatar asked Nov 30 '16 06:11

Ipsita Rout


2 Answers

->STRICT_TRANS_TABLES is responsible for setting MySQL strict mode.

->To check whether strict mode is enabled or not run the below sql:

SHOW VARIABLES LIKE 'sql_mode'; 

If one of the value is STRICT_TRANS_TABLES, then strict mode is enabled, else not. In my case it gave

+--------------+------------------------------------------+  |Variable_name |Value                                     | +--------------+------------------------------------------+ |sql_mode      |STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION| +--------------+------------------------------------------+ 

Hence strict mode is enabled in my case as one of the value is STRICT_TRANS_TABLES.

->To disable strict mode run the below sql:

set global sql_mode=''; 

[or any mode except STRICT_TRANS_TABLES. Ex: set global sql_mode='NO_ENGINE_SUBSTITUTION';]

->To again enable strict mode run the below sql:

set global sql_mode='STRICT_TRANS_TABLES'; 
like image 124
Ipsita Rout Avatar answered Sep 20 '22 14:09

Ipsita Rout


To Change it permanently in ubuntu do the following

in the ubuntu command line

sudo nano /etc/mysql/my.cnf 

Then add the following

[mysqld] sql_mode= 
like image 36
DragonFire Avatar answered Sep 22 '22 14:09

DragonFire