mysql实现定时执行sql语句
检查event事件是否开启
show variables like '%sche%';
如果Value值为OFF,则需要开启
set global event_scheduler=1;
在my.cnf中mysqld域增加:
event_scheduler = 1
通过调用存过实现:
CREATE PROCEDURE test ()
BEGIN
delete rows where expire_time<now()
END;
create event if not exists event_name
on schedule every 5 second
on completion preserve
do call test();