-- 设置 show variables like '%sche%'; set global event_scheduler =1; -- Start存储过程 drop PROCEDURE if exists test; CREATE PROCEDURE test() BEGIN insert into `user` values (1,2,3,4); END -- End存储过程 -- Start 定时任务 drop EVENT if exists e_test ; CREATE event e_test -- 1 每天凌晨2点 ON SCHEDULE EVERY 1 DAY STARTS DATE_ADD(DATE_ADD(CURDATE(), INTERVAL 1 DAY), INTERVAL 2 HOUR) -- 2 每10秒跑 -- on schedule every 10 second on completion preserve do call test(); alter event e_test ON COMPLETION PRESERVE ENABLE; -- End 定时任务