Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

MySQL ʼþµ÷¶ÈÆ÷(Event Scheduler)


Ò»¡¢¸ÅÊö
¡¡¡¡Ê¼þµ÷¶ÈÆ÷ÊÇÔÚ MySQL 5.1 ÖÐÐÂÔöµÄÁíÒ»¸öÌØÉ«¹¦ÄÜ£¬¿ÉÒÔ×÷Ϊ¶¨Ê±ÈÎÎñµ÷¶ÈÆ÷£¬È¡´ú²¿·ÖÔ­ÏÈÖ»ÄÜÓòÙ×÷ϵͳÈÎÎñµ÷¶ÈÆ÷²ÅÄÜÍê³ÉµÄ¶¨Ê±¹¦>ÄÜ¡£ÀýÈ磬Linux ÖÐµÄ crontabe Ö»Äܾ«È·µ½Ã¿·ÖÖÓÖ´ÐÐÒ»´Î£¬¶ø MySQL µÄʼþµ÷¶ÈÆ÷Ôò¿ÉÒÔʵÏÖÿÃëÖÓÖ´ÐÐÒ»¸öÈÎÎñ£¬ÕâÔÚһЩ¶ÔʵʱÐÔÒª>Çó½Ï¸ßµÄ»·¾³Ï¾ͷdz£ÊµÓÃÁË¡£
¡¡¡¡Ê¼þµ÷¶ÈÆ÷ÊǶ¨Ê±´¥·¢Ö´Ðеģ¬ÔÚÕâ¸ö½Ç¶ÈÉÏÒ²¿ÉÒÔ³Æ×÷ÊÇ"ÁÙʱµÄ´¥·¢Æ÷"¡£´¥·¢Æ÷Ö»ÊÇÕë¶Ôij¸ö±í²úÉúµÄʼþÖ´ÐÐһЩÓï¾ä£¬¶øʼþµ÷¶ÈÆ÷ÔòÊÇÔÚijһ¸ö(¼ä¸ô)ʱ¼äÖ´ÐÐһЩÓï¾ä¡£Ê¼þÊÇÓÉÒ»¸öÌض¨µÄÏß³ÌÀ´¹ÜÀíµÄ£¬Ò²¾ÍÊÇËùνµÄ"ʼþµ÷¶ÈÆ÷"¡£ÆôÓÃʼþµ÷¶ÈÆ÷ºó£¬ÓµÓÐ SUPER ȨÏÞµÄÕË»§Ö´ÐÐ SHOW PROCESSLIST ¾Í¿ÉÒÔ¿´µ½Õâ¸öÏß³ÌÁË¡£Í¨¹ýÉ趨ȫ¾Ö±äÁ¿event_scheduler µÄÖµ¼´¿É¶¯Ì¬µÄ¿ØÖÆʼþµ÷¶ÈÆ÷ÊÇ·ñÆôÓá£
(root:localhost:)test> SET GLOBAL event_scheduler = ON;
(root:localhost:)test> show processlist\G
*************************** 4. row ***************************
     Id: 46147
   User: event_scheduler
   Host: localhost
     db: NULL
Command: Daemon
   Time: 1
  State: Waiting on empty queue
   Info: NULL
¡¡¡¡ÈçÉÏ£¬¸ÃÏ̵߳ÄËùÓÐÕßÊÇ event_scheduler¡£
¡¡¡¡¶þ¡¢Ó¦Óð¸Àý
¡¡¡¡±¾°¸ÀýÊÇÀûÓà event scheduler µÄÌØÐÔ£¬Ã¿ÃëÖÓµ÷ÓÃÒ»´Î´æ´¢¹ý³Ì£¬ÓÃÓÚÅÐ¶Ï SLAVE ÊÇ·ñÕý³£ÔËÐУ¬Èç¹û·¢ÏÖ SLAVE ¹Ø±ÕÁË£¬ºöÂÔ 0 ´Î´íÎó£¬È»ºóÖØÐÂÆô¶¯ SLAVE¡£
¡¡¡¡Ê×ÏÈ´´½¨´æ´¢¹ý³Ì
delimiter //
create procedure `Slave_Monitor`()
begin
SELECT VARIABLE_VALUE INTO @SLAVE_STATUS
from information_schema.GLOBAL_STATUS
WHERE VARIABLE_NAME='SLAVE_RUNNING';
IF ('ON' != @SLAVE_STATUS) THEN
 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=0;
 SLAVE START;
END IF;
end; //
delimiter ;
¡¡¡¡ÓÉÓÚ´æ´¢¹ý³ÌÖÐÎÞ·¨µ÷ÓÃÀàËÆ SHOW SLAVE STATUS ÕâÑùµÄÓï¾ä£¬Òò´ËÎÞ·¨µÃµ½È·Çеĸ´ÖÆ´íÎóÐÅÏ¢ºÍ´íÎó´úÂ룬²»ÄܽøÒ»²½µÄ´¦Àí SLAVE Í£Ö¹µÄ¸÷ÖÖÇé¿ö¡£
¡¡¡¡½Ó×Å£¬´´½¨ÈÎÎñ
CREATE EVENT IF NOT EXISTS `Slave_Monitor`
ON SCHEDULE EVERY 5 SECOND
ON COMPLETION PRESERVE
DO
CALL Slave_Monitor();
¡¡¡¡´´½¨ÁËÒ»¸öÈÎÎñ£¬Ã¿ 5ÃëÖÓ Ö´ÐÐÒ»´Î£¬ÈÎÎñ½áÊøºóÒÀ¾É±£Áô¸ÃÈÎÎñ£¬¶ø²»ÊÇɾ³ý¡


Ïà¹ØÎĵµ£º

mysql±¸·ÝÃüÁî


±¸·ÝÊý¾Ý¿âÃüÁî:
mysqldump -u root --password=root --database  helloworld
>helloworld_backup.sql
ÆäËûÓ÷¨:
1.µ¼³öÕû¸öÊý¾Ý¿â
mysqldump -u Óû§Ãû -p Êý¾Ý¿âÃû > µ¼³öµÄÎļþÃû  
mysqldump -u wcnc -p smgp_apps_wcnc > wcnc.sql
2.µ¼³öÒ»¸ö±í
mysqldump -u Óû§Ãû -p Êý¾Ý¿âà ......

jbpm4°²×°ÔÚÒÑÓеÄtomcatÓëmysqlÏÂ

1.JBPM4.3ÏÂÔØ(http://sourceforge.net/projects/jbpm)
2.ant°²×°:jBPMÏÂÔØ°üinstallĿ¼ÖÐÓÐÒ»¸öantµÄbuild.xmlÎļþ,ʹÓÃant -pÄã¿ÉÒÔ¿´µ½ËùÓеݲװ
    demo.setup.jboss£º°²×°jboss£¬°Ñjbpm°²×°µ½jbossÖУ¬ Æô¶¯jboss£¬´´½¨jbpmÊý¾Ý¿â±í½á¹¹£¬²¿ÊðʵÀý£¬¼ÓÔØʵÀýÉí·ÝÈÏÖ¤ÐÅÏ¢£¬ °²×°²¢Æô¶¯eclipse
&n ......

mysqlµÄµ¼ÈëºÍµ¼³ö

1¡¢µ¼³ö
´ÓmysqlÊý¾Ý¿âÖе¼³ö´óÁ¿Êý¾Ý£¬ÍƼömysqldump ÃüÁÓÃÃüÁîµÄÓеãÔÚÓڱȹ¤¾ßÁé»î£¬¿ÉÒÔͨ¹ýÉèÖÃÃüÁîµÄ²ÎÊýÀ´¸ù¾ÝÌõ¼þµ¼³öÒ»¸ö±íÖеIJ¿·ÖÊý¾Ý
ÀýÈ磺½«Ò»¸ö±íµÄÊý¾Ý°´ÕÕÒ»¶¨µÄÌõ¼þµ¼³öµ½d:\sql1.sqlÎļþÖÐ
D:\MySQL5\bin>mysqldump -uÓû§Ãû -pÃÜÂë --no-create-db=TRUE --no-create-inf
o=TRUE --add-drop-t ......

mysql Ìí¼ÓÓû§µÄÃüÁî

Ò»¡¢´´½¨Óû§µÄÃüÁî
mysql> create user 'username'@'localhost' identified by 'password';
Query OK, 0 rows affected (0.06 sec)
¶þ¡¢¸øмÓÓû§ÊÚÓèȨÏÞ
mysql> grant all privileges on test.* to 'username'@'localhost';
Query OK, 0 rows affected (0.00 sec)
˵Ã÷£ºÕâÌõÃüÁîÊÚÓè username ¶ÔÊý¾Ý¿â te ......

MySQL COUNT SUM

 select
count(*) as mcount ,
left(create_time,10) as ptime ,
count(if(receive_msg is null,id,null)) as nullcount ,
count(if(receive_msg = '1',receive_msg,null)) as apfcount ,
count(if(receive_msg = '2',receive_msg,null)) as dttcount ,
count(if(receive_msg = '3',receive_ms ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ