David Angel
David Angel

Reputation: 991

Is there a query to toggle the general_log global setting on/off?

Can I simply toggle a (GLOBAL) variable's state with a query? That is, if it's 'ON' make it 'OFF' and if it's 'OFF' make it 'ON'.

I tried this:

SET GLOBAL general_log = IF(general_log = 'ON', 'OFF', 'ON')

but that produces an error.

Upvotes: 3

Views: 206

Answers (1)

Bohemian
Bohemian

Reputation: 425083

Try this:

set global general_log = if (@@general_log, 'OFF', 'ON')

Note that @@general_log is either 0 or 1 (it's a bit type) and in MySQL these values are false and true respectively.

Upvotes: 3

Related Questions