mysql定时任务,每天凌晨1点执行

执行mysql语句 DO后是需要执行的sql

每天凌晨1点执行

CREATE EVENT IF NOT EXISTS temp_event   
    ON SCHEDULE EVERY 1 DAY STARTS DATE_ADD(DATE_ADD(CURDATE(), INTERVAL 1 DAY), INTERVAL 1 HOUR)   
    ON COMPLETION PRESERVE ENABLE   
    DO update users set support=0 where support=1;

每隔一分钟执行

CREATE event IF NOT EXISTS temp_event ON SCHEDULE EVERY 1 MINUTE   
ON COMPLETION PRESERVE   
DO update users set support=0 where support=1;

查看定时任务

 SELECT * FROM information_schema.events; 

关闭定时任务

DROP event temp_event;

你可能感兴趣的:(mysql)