#查看Mysql的定时器是否开启
show variables like 'event_scheduler';
#开启Mysql定时器
SET GLOBAL event_scheduler = 1;
#关闭Mysql定时器
SET GLOBAL event_scheduler = 0;
#开启Mysql的定时器后,下面的定时事件才能正常执行
#创建一个定时事件,每5秒执行一次过程update_order_tripstatus()
CREATE EVENT
IF NOT EXISTS event_updateorder_tripstatus ON SCHEDULE EVERY 5 SECOND ON COMPLETION PRESERVE DO
call update_order_tripstatus()
#开启一个定时事件
ALTER EVENT event_updateorder_tripstatus ON COMPLETION PRESERVE ENABLE;
#停止一个定时事件
ALTER EVENT event_updateorder_tripstatus ON COMPLETION PRESERVE DISABLE;
Mysql创建定时事件,定时器
点赞
收藏