查看event是否开启
show variables like '%sche%';
将事件计划开启(为no表示已开启为off表示关闭)
set global event_scheduler =1;
创建存储过程fw_shop_day()
CREATE PROCEDURE fw_shop_day ()
BEGIN
/*需要执行的sql语句*/
END;
创建事件 e_fw_shop_day
create event if not exists e_fw_shop_day -- 事件名称
on schedule every 1 DAY STARTS date_add(date(curdate() + 1),interval 0 hour) -- 每天凌晨执行
on completion preserve
do call fw_shop_day(); -- 需要执行的存储过程
关闭事件任务
alter event e_fw_shop_day ON
COMPLETION PRESERVE DISABLE;
开户事件任务
alter event e_fw_shop_day ON
COMPLETION PRESERVE ENABLE;