Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable mysql strict mode globally and have it stay on?

Tags:

mysql

strict

How do I enable MySQL strict mode globally, and have it stay on?

I have tried these commands:

SET sql_mode = TRADITIONAL;
SET sql_mode = ANSI_QUOTES;

But they only set the mode for the current session.

like image 573
Chris Muench Avatar asked Apr 19 '11 18:04

Chris Muench


People also ask

How do I set global mode in SQL?

You can set the SQL_MODE either from the command line (the --sql-mode option) or by setting the sql_mode system variable. SET sql_mode = 'modes'; SET GLOBAL sql_mode = 'modes'; The session value only affects the current client, and can be changed by the client when required.


1 Answers

To set the SQL mode at server startup, use: - the --sql-mode="modes" option on the command line, or - sql-mode="modes" in an option file such as my.cnf (Unix operating systems) or my.ini (Windows). ("modes" is a list of different modes separated by commas.)

Reference: https://dev.mysql.com/doc/refman/5.0/en/sql-mode.html

like image 132
ABC Avatar answered Oct 07 '22 22:10

ABC