Mysql 查看定时器 打开定时器 设置定时器时间
2017-02-21 17:54
417 查看
1.查看是否开启evevt与开启evevt。 1.1、MySQL evevt功能默认是关闭的,可以使用下面的语句来看evevt的状态,如果是OFF或者0,表示是关闭的。 show VARIABLES LIKE '%sche%'; 1.2、开启evevt功能 SET GLOBAL event_scheduler = 1; 2.创建定时器的过程 2.1、创建测试表test drop table if exists test; create table test ( id int(11) not null auto_increment primary key, time datetime not null ) engine=innodb default charset=utf8; 2.2、创建evevt要调用的存储过程test_proce delimiter // drop procedure if exists test_proce// create procedure test_proce() begin insert into test(time) values(now()); end// delimiter ; 2.3、开启evevt(要使定时起作用,MySQL的常量GLOBAL event_scheduler必须为on或者是1) 执行show variables like 'event_scheduler';查看evevt是否开启; 若没开启执行set global event_scheduler='on'; 2.4、创建事件test_event(其作用:每隔一秒自动调用test_proce()存储过程) drop event if exists test_event; create event test_event on schedule every 1 second on completion preserve disable do call test_proce(); 2.5、开启事件test_event alter event test_event on completion preserve enable; 2.6、关闭事件test_event alter event test_event on completion preserve disable; 2.7、查看表test select * from test; 3.查看自己创建的event 如果要查看更加详细的信息,你需要root用户的授权,如果是你自己的数据库你可以用下面语句查看 select * from mysql.event; 下面的我的evevt的查看结果 mysql创建定时器(event),查看定时器,打开定时器,设置定时器时间 4.event的时间设置 设置event很简单,但是麻烦的是如何设置执行的时间,网上找了一些,自己总结了一下。 先看语句,如下面这个 CREATE EVENT test_event ON SCHEDULE EVERY 1 DAY STARTS '2012-09-24 00:00:00' ON COMPLETION PRESERVE ENABLE DO CALL test_procedure(); EVERY 后面的是时间间隔,可以选 1 second,3 minute,5 hour,9 day,1 month,1 quarter(季度),1 year 从2013年1月13号0点开始,每天运行一次 ON SCHEDULE EVERY 1 DAY STARTS '2013-01-13 00:00:00' 从现在开始每隔九天定时执行 ON SCHEDULE EVERY 9 DAY STARTS NOW() ; 每个月的一号凌晨1 点执行 on schedule every 1 month starts date_add(date_add(date_sub(curdate(),interval day(curdate())-1 day),interval 1 month),interval 1 hour); 每个季度一号的凌晨1点执行 on schedule every 1 quarter starts date_add(date_add(date(concat(year(curdate()),'-',elt(quarter(curdate()),1,4,7,10),'-',1)),
interval 1 quarter),interval 1 hour); 每年1月1号凌晨1点执行 on schedule every 1 quarter starts date_add(date_add(date(concat(year(curdate()),'-',elt(quarter(curdate()),1,4,7,10),'-',1)),
interval 1 quarter),interval 1 hour);
相关文章推荐
- mysql创建定时器(event),查看定时器,打开定时器,设置定时器时间
- mysql创建定时器(event),查看定时器,打开定时器,设置定时器时间
- Mysql 查看定时器 打开定时器 设置定时器时间
- mysql创建定时器(event),查看定时器,打开定时器,设置定时器时间
- mysql创建定时器(event),查看定时器,打开定时器,设置定时器时间
- mysql创建定时器(event),查看定时器,打开定时器,设置定时器时间
- mysql创建定时器(event),查看定时器,打开定时器,设置定时器时间
- mysql创建定时器(event),查看定时器,打开定时器,设置定时器时间
- mysql创建定时器(event),查看定时器,打开定时器,设置定时器时间
- mysql创建定时器(event),查看定时器,打开定时器,设置定时器时间
- mysql创建定时器(event),查看定时器,打开定时器,设置定时器时间
- mysql创建定时器(event),查看定时器,打开定时器,设置定时器时间
- 查看mysql连接情况,以及连接超时时间设置
- mysql查看连接数和状态,设置连接数和超时时间
- mysql时间查看以及定时器相关操作
- MySQL设置默认时间
- 【转】查看mysql语句运行时间的2种方法
- Hibernate MySQL设置 timestamp 为插入时间
- 查看mysql语句运行时间的2种方法
- linux系统下查看和设置日期时间的命令