How to set global sql_mode in mysql?
Linode
Linode Staff
I am having issues when the SQL server restarts.
How do I configure MySQL so that that when the sql server restarts, the only SQL MODE that will be restored are "ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER"?
1 Reply
As far as I know, you will need to set this mode within /etc/my.cnf in the [mysqld] section of the file:
[mysqld]
sql_mode = ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER
This should cause your mode to persist even when the server is restarted. You can do this with any of the available modes as well.
If you just run:
SET GLOBAL sql_mode = 'ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER';
It will not save the mode globally, but just within that session.