tags:

views:

32

answers:

1

I had a client who had MySQL Strict which brought up a few errors in my MySQL code... I didn't even know there was a MySQL Strict. I've fixed up a lot of the issues but I want to run some further tests on my local server.

How do I enable MySQL Strict for testing purposes and then disable it when I no longer want it?

+2  A: 

From the docs:

You can change the SQL mode at runtime by using a SET [GLOBAL|SESSION] sql_mode='modes' statement to set the sql_mode system value. Setting the GLOBAL variable requires the SUPER privilege and affects the operation of all clients that connect from that time on. Setting the SESSION variable affects only the current client. Any client can change its own session sql_mode value at any time.

(Emphasis mine)

Example:

SET SESSION sql_mode='STRICT_ALL_TABLES';
Matt
Hey Matt,I tried that and it said it worked fine... However when I run either query:SELECT @@GLOBAL.sql_mode;SELECT @@SESSION.sql_mode;It comes up with the results a blank. Does that mean it hasn't worked?
Ben Sinclair
@Ben If it had worked, you would've received a resultset containing your mode.. so it sounds like it hasn't worked. If all else fails, you can run MySQL loacally and pass `--sql-mode='STRICT_ALL_TABLES'` through the terminal.
Matt