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
Ïà¹ØÎĵµ£º
http://www.blogjava.net/Alpha/archive/2007/07/23/131912.html
//Ö÷¼ü549830479
alter table tabelname add new_field_id int(5) unsigned default 0 not null auto_increment ,add primary key (new_field_id);
//Ôö¼ÓÒ»¸öÐÂÁÐ549830479
alter table t2 add d timestamp;
alter table infos add ex tinyint n ......
use mysql
update user set Password=password('newpassword') where User='root';
flush privileges;
Ê×ÏÈÒªÉùÃ÷Ò»µã£¬´ó²¿·ÖÇé¿öÏ£¬ÐÞ¸ÄMySQLÊÇÐèÒªÓÐmysqlÀïµÄrootȨÏ޵ģ¬
ËùÒÔÒ»°ãÓû§ÎÞ·¨¸ü¸ÄÃÜÂ룬³ý·ÇÇëÇó¹ÜÀíÔ±¡£
·½·¨Ò»
ʹÓÃphpmyadmin£¬ÕâÊÇ×î¼òµ¥µÄÁË£¬ÐÞ¸Ämysql¿âµ ......
#include "winsock.h"
#include "mysql.h"
void query_example(void)
{
MYSQL *pDbCon = NULL;
char *pszHost = "localhost";
char *pszUser = "guest";
char *pszPsw = "";
char *pszDbName = "mysql_db_name";
int iPort = 3306;
pDbCon = mysql_init((MYSQL*) 0);
if (NULL != pDbCon)
{
......
·½·¨Ò»£º
ʹÓÃMySQLÍƳöµÄMySQL Connector/Net×é¼þ£¬ ¸Ã×é¼þÊÇMySQLΪADO.NET·ÃÎÊMySQLÊý¾Ý¿âÉè¼ÆµÄ.NETרÓ÷ÃÎÊ×é¼þ¡£Íê³É¸Ã×é¼þºó£¬ÐèÒªÔÚÏîÄ¿ÖÐÒýÓÃÕâ¸ö×é¼þ£¬Ò²¿ÉÒÔÖ±½ÓÔÚÅäÖÃÎļþµÄ<assemblies>½ÚµãÄÚÌí¼ÓÏÂÃæµÄ½Úµã£º
<add assembly="MySql.Data, Version=5.1.5.0, Culture=neutral, PublicKeyToken=C5687 ......
mysql×Ö·û¼¯ÉèÖúͲéѯÎÊÌ⣨ת£©
2010-04-14 11:33
MySQLµÄ×Ö·û¼¯Ö§³Ö(Character Set Support)ÓÐÁ½¸ö·½Ã棺
×Ö·û¼¯(Character set)ºÍÅÅÐò·½Ê½(Collation)¡£
¶ÔÓÚ×Ö·û¼¯µÄÖ§³Öϸ»¯µ½Ëĸö²ã´Î:
·þÎñÆ÷(server)£¬Êý¾Ý¿â(database)£¬Êý¾Ý±í(table)ºÍÁ¬½Ó(connection) ......