How to set global sql_mode in mysql?

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.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct