//查看事件调度器是否开启
SHOW VARIABLES LIKE 'event_scheduler';
//开启事件调度器
SET GLOBAL event_scheduler = ON;
//创建定时事件
DELIMITER $$
CREATE EVENT IF NOT EXISTS myEvent
ON SCHEDULE EVERY 60 SECOND
ON COMPLETION PRESERVE
DO
BEGIN
DELETE FROM netrelay where ReceivedAt<(CURRENT_TIMESTAMP() + INTERVAL -5 DAY);
END;
$$;
//查看所有事件
show events;
//查看事件执行记录
select * from mysql.event;
//查看进程列表
show processlist;
//删除事件
drop event if exists eventName;
//查看数据库大小
select concat(round(sum(DATA_LENGTH/1024/1024),2),'M') from information_schema.tables;