1.查看事件是否开启
1-1.show variables like
'event_scheduler'
;
1-2.select @@event_scheduler;
1-3.show processlist;
如果event_scheduler=off 没有开启 on开启
1-4开启event_scheduler
set
global
event_scheduler =
'on'
;
//注意:还是要在my.cnf中添加event_scheduler=ON。否则mysql重启事件又会回到原来的状态了。
2.查看事件
select * from mysql.event
3.创建事件
//每3秒执行一次插入
create event
if
not exists test on schedule every 3 second
on completion preserve
do
insert into test(id,t1)values(
''
,now());
4.删除事件