David Angel David Angel - 4 months ago 7x
MySQL Question

Is there a simple MySQL query to toggle general_log on and off?

I'm wanting to know if I can simply switch a (GLOBAL) variable's state on and of with a query like this:

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

...but that doesn't seem to work.


Try this:

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