凌寒飘香

____成风破浪会有时,直把云帆济沧海!

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: :: 管理 ::

1.定时调用 存储过程

DELIMITER $$

ALTER DEFINER=`root`@`localhost` EVENT `event_stroke_ArchivesReportDataRefreshDaily` ON SCHEDULE EVERY 1 DAY STARTS '2012-01-01 00:10:00' ON COMPLETION NOT PRESERVE ENABLE DO CALL proc_stroke_ArchivesReportDataRefresh()$$

DELIMITER ;

 

2.定时执行sql语句

DELIMITER $$

ALTER DEFINER=`root`@`localhost` EVENT `event_stroke_ArchivesReportDataRefreshDaily` ON SCHEDULE EVERY 1 DAY STARTS '2013-08-08 14:49:00' ON COMPLETION NOT PRESERVE ENABLE DO INSERT INTO test(OrgID,valuetime) VALUES(3,NOW())$$

DELIMITER ;

 

mysql version   V5.5.12

打开开关

SET GLOBAL event_scheduler = 1;
SHOW VARIABLES LIKE 'event_scheduler';

但是关机后会还原为off

永久生效,需在my.ini设置如下

# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this
# file.
#
[mysqld]

# The TCP/IP Port the MySQL Server will listen on
port=3306

event_scheduler = 1

重启mysql服务

posted on 2013-08-08 14:53  凌寒飘香  阅读(205)  评论(0编辑  收藏  举报