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

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

每天凌晨1点执行

 
  1. CREATE EVENT IF NOT EXISTS temp_event

  2. ON SCHEDULE EVERY 1 DAY STARTS DATE_ADD(DATE_ADD(CURDATE(), INTERVAL 1 DAY), INTERVAL 1 HOUR)

  3. ON COMPLETION PRESERVE ENABLE

  4. DO update users set support=0 where support=1;

每隔一分钟执行

 
  1. CREATE event IF NOT EXISTS temp_event ON SCHEDULE EVERY 1 MINUTE

  2. ON COMPLETION PRESERVE

  3. DO update users set support=0 where support=1;

查看定时任务

 SELECT * FROM information_schema.events; 

关闭定时任务

DROP event temp_event;

你可能感兴趣的:(mysql)