show variables like ‘%sche%’;

set global event_scheduler =1;

CREATE PROCEDURE test ()
BEGIN
update examinfo SET endtime = now() WHERE id = 14;
END;

create event if not exists e_test
on schedule every 30 second
on completion preserve
do call test();

关闭事件任务

alter event e_test ON
COMPLETION PRESERVE DISABLE;

开启事件任务

alter event e_test ON
COMPLETION PRESERVE ENABLE;

以上测试均成功,测试环境为mysql 5.4.2-beta-community mysql community server(GPL)

以上的相关内容就是对MySQL定时执行的介绍,望你能有所收获。

mysql 计划任务重启后消失

我们只要修改一配置即可

event_scheduler在mysql的config中设置为OFF有关。去mysql中将配置改为ON则就搞定了。

发表评论

电子邮件地址不会被公开。 必填项已用*标注