1、查看事件是否开启
SHOW VARIABLES LIKE ‘event_scheduler‘;
2、开启事件
SET GLOBAL event_scheduler = ON;
3、创建事件
DELIMITER $$
-- SET GLOBAL event_scheduler = ON$$ -- required for event to execute but not create
CREATE /*[DEFINER = { user | CURRENT_USER }]*/ EVENT `db_name`.`everyday_refresh`
ON SCHEDULE EVERY 1 DAY STARTS ‘2014-07-22 11:00:00‘ ON COMPLETION PRESERVE DISABLE ON SLAVE
DO
BEGIN
UPDATE `tb_times` SET remanent_times = GREATEST(`remanent_times`,new_times);
END$$
DELIMITER ;