– 如果数据量过大,请将数据库的超时时间设长一点。
– 查看写数据的超时时间
SHOW VARIABLES LIKE “%timeout%”
在my.ini文件中[mysqld]下增加一行net_write_timeout=600。重启MySQL服务。
(原值:net_write_timeout=60,单位s)
#定期删数据
drop procedure if EXISTS del_t_data;
create procedure del_t_data(
in date_inter int(11)
)
begin
delete from t_table where d_time < date_sub(curdate(), interval date_inter day);
END
;
drop event if EXISTS del_event_t;
create event del_event_t on schedule EVERY 1 day STARTS ‘2020-03-11 01:00:00’ ON COMPLETION PRESERVE ENABLE do call del_t_data(2);
- 删除两天前的数据
- 一般将事件的执行时间设置成晚上休息时段