#查看定时任务是否开启
SHOW VARIABLES LIKE 'event_scheduler';
#开启定时任务
-- SET GLOBAL event_scheduler = ON;
-- select TO_DAYS(NOW())-TO_DAYS(cur_time) from student
#每50秒刷新删除表数据大于三十天的
DELIMITER $$
DROP EVENT IF EXISTS deleteLog;
CREATE EVENT deleteLog
ON SCHEDULE EVERY 50 SECOND
ON COMPLETION PRESERVE
DO BEGIN
delete from student where TO_DAYS(now())-TO_DAYS(student.cur_time)>30;
END$$
DELIMITER;
查看定时任务是否设置成功
select * from mysql.event;