MySQL 5.1ÐÂÌØÐÔ֮ʼþµ÷¶ÈÆ÷(Event Scheduler)
À´×Ô£ºhttp://www.sofee.cn/blog/2007/07/18/91/
MySQL 5.1ÐÂÌØÐÔ֮ʼþµ÷¶ÈÆ÷(Event Scheduler)
CREATE-EVENT, cron, Event-Scheduler, ´¥·¢Æ÷, ¼Æ»®ÈÎÎñ, MySQL,Triggers, ʼþµ÷¶ÈÆ÷, ×÷Òµµ÷¶È
July 18, 2007 at 20:34:50 · Filed under MySQL
Ò»¡¢Ç°ÑÔ
×ÔMySQL5.1.6Æð£¬Ôö¼ÓÁËÒ»¸ö·Ç³£ÓÐÌØÉ«µÄ¹¦Äܖʼþµ÷¶ÈÆ÷(Event Scheduler)£¬¿ÉÒÔÓÃ×ö¶¨Ê±Ö´ÐÐijЩÌض¨ÈÎÎñ£¨ÀýÈ磺ɾ³ý¼Ç¼¡¢¶ÔÊý¾Ý½øÐлã×ܵȵȣ©£¬À´È¡´úÔÏÈÖ»ÄÜÓɲÙ×÷ϵͳµÄ¼Æ»®ÈÎÎñÀ´Ö´ÐеŤ×÷¡£¸üÖµµÃÒ»ÌáµÄÊÇMySQLµÄʼþµ÷¶ÈÆ÷¿ÉÒÔ¾«È·µ½Ã¿ÃëÖÓÖ´ÐÐÒ»¸öÈÎÎñ£¬¶ø²Ù×÷ϵͳµÄ¼Æ»®ÈÎÎñ£¨È磺LinuxϵÄCRON»òWindowsϵÄÈÎÎñ¼Æ»®£©Ö»Äܾ«È·µ½Ã¿·ÖÖÓÖ´ÐÐÒ»´Î¡£¶ÔÓÚһЩ¶ÔÊý¾ÝʵʱÐÔÒªÇó±È½Ï¸ßµÄÓ¦Óã¨ÀýÈ磺¹ÉƱ¡¢ÅâÂÊ¡¢±È·ÖµÈ£©¾Í·Ç³£Êʺϡ£
ʼþµ÷¶ÈÆ÷ÓÐʱҲ¿É³ÆΪÁÙʱ´¥·¢Æ÷(temporal triggers)£¬ÒòΪʼþµ÷¶ÈÆ÷ÊÇ»ùÓÚÌض¨Ê±¼äÖÜÆÚ´¥·¢À´Ö´ÐÐijЩÈÎÎñ£¬¶ø´¥·¢Æ÷(Triggers)ÊÇ»ùÓÚij¸ö±íËù²úÉúµÄʼþ´¥·¢µÄ£¬Çø±ðÒ²¾ÍÔÚÕâÀï¡£
ÔÚʹÓÃÕâ¸ö¹¦ÄÜ֮ǰ±ØÐëÈ·±£event_schedulerÒÑ¿ªÆô£¬¿ÉÖ´ÐÐ
SET GLOBAL event_scheduler = 1;
»ò
SET GLOBAL event_scheduler = ON;
À´¿ªÆô£¬Ò²¿ÉÒÔÖ±½ÓÔÚÆô¶¯ÃüÁî¼ÓÉÏ“–event_scheduler=1”£¬ÀýÈ磺
mysqld ... --event_scheduler=1
Òª²é¿´µ±Ç°ÊÇ·ñÒÑ¿ªÆôʼþµ÷¶ÈÆ÷£¬¿ÉÖ´ÐÐÈçÏÂSQL£º
SHOW VARIABLES LIKE 'event_scheduler';
»ò
SELECT @@event_scheduler;
»ò
SHOW PROCESSLIST;
¶þ¡¢´´½¨Ê¼þ(CREATE EVENT)
ÏÈÀ´¿´Ò»ÏÂËüµÄÓï·¨£º
CREATE EVENT [IF NOT EXISTS] event_name
ON SCHEDULE schedule
[ON COMPLETION [NOT] PRESERVE]
[ENABLE | DISABLE]
[COMMENT 'comment']
DO sql_statement;
schedule:
AT timestamp [+ INTERVAL interval]
| EVERY interval [STARTS timestamp] [ENDS timestamp]
interval:
quantity {YEAR | QUARTER | MONTH | DAY | HOUR | MINUTE |
WEEK | SECOND | YEAR_MONTH | DAY_HOUR | DAY_MINUTE |
DAY_SECOND | HOUR_MINUTE | HOUR_SECOND | MINUTE_SECOND}
1) Ê×ÏÈÀ´¿´Ò»¸ö¼òµ¥µÄÀý×ÓÀ´ÑÝʾÿÃë²åÈëÒ»Ìõ¼Ç¼µ½Êý¾Ý±í
USE test;
CREATE TABLE aaa (timeline TIMESTAMP);
CREATE EVENT e_test_insert
ON SCHEDULE EVERY 1 SECOND
DO INS
Ïà¹ØÎĵµ£º
innodb_buffer_pool_size
Èç¹ûÓÃInnodb£¬ÄÇôÕâÊÇÒ»¸öÖØÒª±äÁ¿¡£Ïà¶ÔÓÚMyISAMÀ´Ëµ£¬Innodb¶ÔÓÚbuffer size¸üÃô¸Ð¡£MySIAM¿ÉÄܶÔÓÚ´óÊý¾ÝÁ¿Ê¹ÓÃĬÈϵÄkey_buffer_sizeÒ²»¹ºÃ£¬µ«InnodbÔÚ´óÊý¾ÝÁ¿Ê±ÓÃĬÈÏÖµ¾Í¸Ð¾õÔÚÅÀÁË¡£ InnodbµÄ»º³å³Ø»á»º´æÊý¾ÝºÍË÷Òý£¬ËùÒÔ²»ÐèÒª¸øϵͳµÄ»º´æÁô¿Õ¼ä£¬Èç¹ûÖ»ÓÃInnodb£¬¿ÉÒÔ°ÑÕâ¸öÖµÉèΪ ......
Unix&Linux£º
1.ÓÃroot»òÕßÔËÐÐmysqldµÄÓû§µÇ¼ϵͳ£»
2£®ÀûÓÃkillÃüÁî½áÊøµômysqldµÄ½ø³Ì£»
3£®Ê¹ÓÃ--skip-grant-tables²ÎÊýÆô¶¯MySQL Server
shell>mysqld_safe --skip-grant-tables &
4.Ϊroot@localhostÉèÖÃÐÂÃÜÂë
shell>mysqladmin -u root flush-privileges password "newpassword" ......
Author: Ivan@mysqlab.net/Ì·¿¡Çà תÔØÇë×¢Ã÷À´Ô´URIÁ´½Ó:
http://www.mysqlab.net/blog/2009/04/mysql-54µÄÐÂÌØÐÔ½âÎö/
MySQL 5.4 Ö®ËùÒÔÃüÃûΪ5.4£¬¶ø²»ÊÇ5.2 ÊÇÒòΪ֮ǰµÄ5.2°æ±¾±»ÃüÃûΪ6.0ÁË£¨Õâ¸öÓ¦¸ÃÊÇÉÌÒµÉϵÄÔÒò£¬¾ÍÏñjava1.6±»ÃüÃûΪ6.0£©¡£ÏÖÔÚµÄ5.4 preview release ÊÇÔÚµ±Ç°MySQL5.1µÄ»ù´¡ÉÏ£¬¶Ô Innodb ½ø ......
Ò». Æô¶¯²ÎÊýÓÅ»¯
ÐÞ¸Ä my.cnf (»òÕßmy.ini)£¬¼ÓÈë/ÐÞ¸ÄÒÔϼ¸ÐÐ
#É趨»º´æµÄÁ¬½ÓÊý,½ÚÊ¡Á¬½ÓʱµÄ¿ªÏú
back_log = 64
#½ûÓÃÎļþϵͳÍⲿËø
external-locking = 0
#½ûÓÃBDB,Èç¹ûÄãȷʵ²»ÐèÒªµÄ»°,innodbÒ²ÊÇÈç´Ë
skip-bdb
#Ë÷Òý»º³å,Èç¹ûÊÇרÓõÄÊý¾Ý¿â·þÎñÆ÷,¿ÉÒÔÉèÖøߴï·þÎñÆ÷ÄÚ´æµÄÒ»°ë,Èç¹û²»ÊÇרÓõÄ,
#»¹ÊÇÉ ......
×î½üÔÚѧϰSSH£¬ÓÉÓÚΪÁ˽ÚÔ¼Äڴ棬ËùÒÔ¾Í×¼±¸Ê¹ÓÃMYSQL´úÌæOracle£¬ÎªÁ˸üÉîÒ»²½µØÁ˽âMySQL£¬ÓÚÊǾͼƻ®°²×°noinstall°æ±¾£¬Õâ°æ±¾±È°²×°°æ¿ÉÂ鷳һЩ£¬ÌرðÊÇÅäÖ÷½Ã棬Èç¹ûÅäÖúõĻ°¾Í¿ÉÒÔÔÚһ̨»úÆ÷ÉÏÔËÐжà¸ö°æ±¾µÄMYSQL£¬ÔÚÍøÉÏÕÒÁËÇ°±²ÃǵıʼǺóѧϰÍê±ÏºóÔټǼһ±Ê£¬¾ÍÎÒÕâ¼ÇÐÔ£¬¹À¼Æà ......