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

MySQL EVENT


MySQL EVENT 
À´Ô´£ºhttp://samyu.blog.51cto.com/344284/146011
event_scheduler:
The MySQL event scheduler is a thread that runs in the background looking for events to execute. It spends a lot of time sleeping -- and won't do anything unless the new global variable "event_scheduler" is set to ON (1). So if you want to take advantage of this feature, do the following:
SET GLOBAL event_scheduler = 1;
To turn the feature off, do:
SET GLOBAL event_scheduler = 0;
As with all "SET GLOBAL" statements, you need the SUPER privilege to change the setting of the event_scheduler variable.
It is also possible to start the server with:
mysqld ... --event_scheduler=1
You can see what the current state of affairs is with
SHOW VARIABLES LIKE 'event_scheduler';
or
SELECT @@event_scheduler;
Now let's look at the syntax for events.
Ò»¡¢Ç°ÑÔ
×ÔMySQL5.1.6Æð£¬Ôö¼ÓÁËÒ»¸ö·Ç³£ÓÐÌØÉ«µÄ¹¦Äܖʼþµ÷¶ÈÆ÷(Event Scheduler)£¬¿ÉÒÔÓÃ×ö¶¨Ê±Ö´ÐÐijЩÌض¨ÈÎÎñ£¨ÀýÈ磺ɾ³ý¼Ç¼¡¢¶ÔÊý¾Ý½øÐлã×ܵȵȣ©£¬À´È¡´úÔ­ÏÈÖ»ÄÜÓɲÙ×÷ϵͳµÄ¼Æ»®ÈÎÎñÀ´Ö´ÐеŤ×÷¡£¸üÖµµÃ Ò»ÌáµÄÊÇMySQLµÄʼþµ÷¶ÈÆ÷¿ÉÒÔ¾«È·µ½Ã¿ÃëÖÓÖ´ÐÐÒ»¸öÈÎÎñ£¬¶ø²Ù×÷ϵͳµÄ¼Æ»®ÈÎÎñ£¨È磺LinuxϵÄCRON»òWindowsϵÄÈÎÎñ¼Æ»®£©Ö»Äܾ« È·µ½Ã¿·ÖÖÓÖ´ÐÐÒ»´Î¡£¶ÔÓÚһЩ¶ÔÊý¾ÝʵʱÐÔÒªÇó±È½Ï¸ßµÄÓ¦Óã¨ÀýÈ磺¹ÉƱ¡¢ÅâÂÊ¡¢±È·ÖµÈ£©¾Í·Ç³£Êʺϡ£
ʼþµ÷¶ÈÆ÷ÓÐʱҲ¿É³ÆΪÁÙʱ´¥·¢Æ÷(temporal triggers)£¬ÒòΪʼþµ÷¶ÈÆ÷ÊÇ»ùÓÚÌض¨Ê±¼äÖÜÆÚ´¥·¢À´Ö´ÐÐijЩÈÎÎñ£¬¶ø´¥·¢Æ÷(Triggers)ÊÇ»ùÓÚij¸ö±íËù²úÉúµÄʼþ´¥·¢µÄ£¬Çø±ðÒ²¾ÍÔÚÕâÀï¡£
ÔÚʹÓÃÕâ¸ö¹¦ÄÜ֮ǰ±ØÐëÈ·±£event_schedulerÒÑ¿ªÆô£¬¿ÉÖ´ÐÐ
SET GLOBAL event_scheduler = 1;
---»òÎÒÃÇ¿ÉÒÔÔÚÅäÖÃmy.iniÎļþ ÖмÓÉÏ 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 s


Ïà¹ØÎĵµ£º

mysql ÖРʱ¼äºÍÈÕÆÚº¯Êý

»ù´¡²¿·Ö
Ò»¡¢MySQL »ñµÃµ±Ç°ÈÕÆÚʱ¼ä º¯Êý
1.1 »ñµÃµ±Ç°ÈÕÆÚ+ʱ¼ä£¨date + time£©º¯Êý£ºnow()
mysql> select now();
+---------------------+
| now()               |
+----------------- ......

MySQLÐÔÄÜÓÅ»¯

×÷Õߣºandyao
Ô­ÎÄlink: http://andyao.javaeye.com/admin/show/144033
תÔØÇëÁôÃû
1. ¼ò½é
ÔÚWebÓ¦ÓóÌÐòÌåϵ¼Ü¹¹ÖУ¬Êý¾Ý³Ö¾Ã²ã£¨Í¨³£ÊÇÒ»¸ö¹ØϵÊý¾Ý¿â£©ÊǹؼüµÄºËÐIJ¿·Ö£¬Ëü¶ÔϵͳµÄÐÔÄÜÓзdz£ÖØÒªµÄÓ°Ïì¡£MySQLÊÇĿǰʹÓÃ×î¶àµÄ¿ªÔ´Êý¾Ý¿â£¬µ«ÊÇMySQLÊý¾Ý¿âµÄĬÈÏÉèÖÃÐÔÄܷdz£µÄ²î£¬½ö½öÊÇÒ»¸öÍæ¾ßÊý¾Ý¿â¡£Òò´ËÔÚ ......

WindowsÏ»·¾³±äÁ¿Ð޸ģ¨Éæ¼°MySQLÃüÁîµÄÖ±½ÓÔËÐУ©


ÓÒ¼üÎҵĵçÄÔ->ÊôÐÔ->¸ß¼¶->»·¾³±äÁ¿
¿ÉÒÔ¿´µ½ÓÐÓû§±äÁ¿ºÍϵͳ±äÁ¿
ÔÚÕâÀïÎÒÃÇ¿ÉÒÔ½øÐÐÐ޸Ļ·¾³±äÁ¿
±ÈÈç˵ÎÒÃÇ°²×°ÁËMySQL·þÎñÆ÷£¬Ïë½øÈëMySQLµÄÃüÁîÐеĻ°¾Í±ØÐëÔËÐÐcmd
Èç¹ûûÓÐÉèÖû·¾³±äÁ¿µÄ»°ÎÒÃDZØÐë½øÈëMySQLµÄ°²×°Â·¾¶²ÅÄÜʹÓÃmysql -u root -pÕâ¸öÃüÁî
ÕâÑù»á¸øÎÒÃÇ´øÀ´ºÜ¶àÂé·³£¬ÕâʱºòÎÒÃÇÏëÔ ......

MySQLÖ÷´Ó·þÎñÆ÷µÄһЩ¼¼ÇÉ(ת)

Ö÷´Ó·þÎñÆ÷±íÀàÐ͵ÄÑ¡Ôñ
Ò»°ãµÄ¹²Ê¶ÊÇÖ÷·þÎñÆ÷ʹÓÃinnodb£¬ÊÂÎñ£¬ÐÐËøµÈ¹¦ÄÜÊÇmyisamËùûÓеģ¬¶ÔÐ޸IJÙ×÷¶øÑÔ£¬Ëü¸ü¸ßЧ£»´Ó·þÎñÆ÷ʹÓÃmyisam£¬È«ÎļìË÷¹¦ÄÜÊÇinnodbËùûÓеģ¬¶Ô²éѯ²Ù×÷¶øÑÔ£¬Ëü¸ü¸ßЧ¡£ÕâÑù¾Í¿ÉÒÔ¸÷¾¡ÆäÄÜ¡£
ºÇºÇ£¬Ö÷´Ó¿â¸÷˾ÆäÖ°£¬Ö÷¿â£º×î¿ìµÄËÙ¶È×öÌí¼Óɾ³ýÐ޸IJÙ×÷£¬´Ó¿â£¬×î¿ìµÄËÙ¶È×ö²éѯ²Ù×÷
......

MySql±àÂëÎÊÌâ

      ÎÒͬѧ½ÓÁ˸ö˽»î£¬ÏòÎÒÒªÁËmysqlµÄ°²×°Îļþ¡£×òÍíËûÎÊÎÒÓÐûÓöµ½mysqlµÄÂÒÂëÎÊÌ⣬ÎÒ¸øËûµÄ´ð°¸ÊǵÚÒ»´ÎÓõÄʱºòÓöµ½¹ý£¬ÅäºÃÁ˺ó£¬ÏÖÔÚ¶¼Ã»ÓÐÁË¡£Ëû˵ÔÚÍøÉÏÕÒÁ˺ܶàÎÄÕ£¬ÕÕןÄÁËËùÓÐÅäÖÃÎļþ¶¼Ã»½â¾ö¡£
      ÏëÏëÒ²ÊÇ£¬µ±³õµÚÒ»´ÎÓõÄʱºòÒ²ÊÇÒ»Ñù£¬¸ÄÁËËù ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ