David Angel David Angel - 2 years ago 59
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.

Answer Source

Try this:

set global general_log = if (@@general_log = 0, 'ON', 'OFF')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download