mysql设置定时任务

–查看时间调度器是否开启

SHOW VARIABLES LIKE 'event_scheduler';
SELECT @@event_scheduler;

–开启时间调度器

SET GLOBAL event_scheduler = ON;

–创建定时任务

create event if not exists e_test
on schedule every 30 second
on completion preserve
do call day_update();
CREATE EVENT if not exists event_day_update
ON SCHEDULE EVERY 1 DAY STARTS '2016-01-04 00:20:00'
ON COMPLETION PRESERVE
ENABLE
DO call day_update();  --day_update是存储过程

–开启定时任务

alter event event_day_update ON COMPLETION PRESERVE ENABLE;

–关闭定时任务

alter event event_day_update ON COMPLETION PRESERVE DISABLE;
原文地址:https://www.cnblogs.com/ggzone/p/10121190.html