问题
In MySQL, we can enable the event scheduler by following query:
SET GLOBAL event_scheduler = ON;
Similarly, to turn off the scheduler:
SET GLOBAL event_scheduler = OFF;
But, Is there any query/way to check the status of this event_scheduler whether it's on or off?
回答1:
Use SHOW VARIABLES
SHOW VARIABLES
WHERE VARIABLE_NAME = 'event_scheduler'
回答2:
This should also work:
select @@global.event_scheduler = 'ON'
That is a little easier to use in a stored procedure, where you might want to know if it is ON before turning it on. Note that I tested this on MySQL 5.7 after turning on Event_Scheduler either with ON or 1. In both cases, querying the variable returns 'ON'.
Also, note the quotes are used for querying, but not for setting the variable. A little mysql weirdness for you.
来源:https://stackoverflow.com/questions/39158933/how-to-check-event-scheduler-status-mysql