How to check event scheduler status mysql

…衆ロ難τιáo~ 提交于 2019-11-28 02:37:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!