mysql event

1.定時調用 存儲過程mysql

DELIMITER $$sql

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()$$this

DELIMITER ;spa

 

2.定時執行sql語句server

DELIMITER $$get

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())$$it

DELIMITER ;io

 

mysql version   V5.5.12event

打開開關test

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服務

相關文章
相關標籤/搜索