MySQL 如何检查事件调度程序状态mysql

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39158933/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 21:59:18  来源:igfitidea点击:

How to check event scheduler status mysql

mysqleventsscheduler

提问by JerryGoyal

In MySQL, we can enable the event scheduler by following query:

在 MySQL 中,我们可以通过以下查询启用事件调度程序:

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?

但是,是否有任何查询/方法可以检查此 event_scheduler 的状态是打开还是关闭?

回答by mnv

Use SHOW VARIABLES

使用显示变量

SHOW VARIABLES
WHERE VARIABLE_NAME = 'event_scheduler'

回答by Garr Godfrey

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'.

这在存储过程中更容易使用,您可能想在打开它之前知道它是否打开。请注意,在使用 ON 或 1 打开 Event_Scheduler 后,我在 MySQL 5.7 上对此进行了测试。在这两种情况下,查询变量都返回“ON”。

Also, note the quotes are used for querying, but not for setting the variable. A little mysql weirdness for you.

另外,请注意引号用于查询,而不是用于设置变量。对你来说有点奇怪的 mysql。