3

We have a single MySQL 5.7 server that we need to have in a non-strict mode because some legacy databases require it. However, in our newest app, we'd like the database to enforce strictness (especially NO_ZERO_DATE). Is there a way to override the server-level configurations at the database level?

abeger
  • 6,766
  • 7
  • 41
  • 58

1 Answers1

1

You can change the SQL mode by session with :

SET SESSION sql_mode = 'modes';

According to the documentation :

Setting the SESSION variable affects only the current client.

This could be a workaround to solve your problem. I think there is no direct way to set the SQL mode by database.

Note also :

Important

SQL mode and user-defined partitioning. Changing the server SQL mode after creating and inserting data into partitioned tables can cause major changes in the behavior of such tables, and could lead to loss or corruption of data. It is strongly recommended that you never change the SQL mode once you have created tables employing user-defined partitioning.

Maybe the safer way is to use two instances of MySQL server.

Community
  • 1
  • 1
Ortomala Lokni
  • 56,620
  • 24
  • 188
  • 240
  • "Maybe the safer way is to use two instances of MySQL server." Oh yeah, that's certainly safer. Not sure it's an option, though – abeger Feb 14 '17 at 17:23