ÓÅ»¯MySQL²åÈë·½·¨µÄÎå¸öÃîÕÐ
ÔÎÄÁ´½Ó http://database.51cto.com/art/200904/117957.htm
ÒÔÏÂÊÇÉæ¼°µ½²åÈë±í¸ñµÄ²éѯµÄ5ÖָĽø·½·¨£º
1)ʹÓÃLOAD DATA INFILE´ÓÎı¾ÏÂÔØÊý¾ÝÕ⽫±ÈʹÓòåÈëÓï¾ä¿ì20±¶¡£
2)ʹÓôøÓжà¸öVALUESÁбíµÄINSERTÓï¾äÒ»´Î²åÈ뼸ÐÐÕ⽫±ÈʹÓÃÒ»¸öµ¥ÐвåÈëÓï¾ä¿ì¼¸±¶¡£µ÷Õûbulk_insert_buffer_size±äÁ¿Ò²ÄÜÌá¸ß£¨Ïò°üº¬Ðеıí¸ñÖУ©²åÈëµÄËٶȡ£
3)¿ÉÒÔ¶Ômyisam±í²¢ÐвåÈëConcurrent_insertϵͳ±äÁ¿¿ÉÒÔ±»ÉèÖÃÓÃÓÚÐÞ¸Äconcurrent-insert´¦Àí¡£¸Ã±äÁ¿Ä¬ÈÏÉèÖÃΪ1¡£Èç¹ûconcurrent_insert±»ÉèÖÃΪ0£¬²¢ÐвåÈë¾Í±»½ûÓá£Èç¹û¸Ã±äÁ¿±»ÉèÖÃΪ2£¬ÔÚ±íµÄÄ©¶Ë¿ÉÒÔ²¢ÐвåÈ룬¼´±ã¸Ã±íµÄijЩÐÐÒѾ±»É¾³ý¡£
4)ʹÓòåÈëÑÓ³Ù
Èç¹ûÄãµÄ¿Í»§²»ÄÜ»òÎÞÐèµÈ´ý²åÈëÍê³ÉµÄʱºò£¬ÕâÕкÜÓÐÓᣵ±ÄãʹÓÃMySQL´æ´¢£¬²¢¶¨ÆÚÔËÐÐÐèÒªºÜ³¤Ê±¼ä²ÅÄÜÍê³ÉµÄSELECTºÍUPDATEÓï¾äµÄʱºò£¬Äã»á·¢ÏÖÕâÖÖÇé¿öºÜ³£¼û¡£µ±¿Í»§Ê¹ÓòåÈëÑÓ³Ù£¬·þÎñÆ÷Á¢¿Ì·µ»Ø£¬Èç¹û±íûÓб»ÆäËûÏ̵߳÷Óã¬ÔòÐлáÁжӵȴý±»²åÈ롣ʹÓòåÈëÑÓ³ÙµÄÁíÒ»¸öºÃ´¦¾ÍÊÇ´Ó¶à¸ö¿Í»§²åÈëµÄÇé¿ö»á±»°ó¶¨²¢¼Ç¼ÔÚͬһ¸öblockÖС£Õ⽫±È´¦Àí¶à¸ö¶ÀÁ¢µÄ²åÈëÒª¿ìµÃ¶à¡£
5)²åÈë֮ǰ½«±íËø¶¨(Ö»Õë¶Ô·ÇÊÂÎñ´¦ÀíÐ͵ıí)
Õ⽫Ìá¸ßÊý¾Ý¿âÐÔÄÜ£¬ÒòΪË÷Òý»º³åÇøÖ»ÊÇÔÚËùÓеIJåÈëÓï¾äÍê³Éºó²Å¶Ô´ÅÅ̽øÐÐÒ»´ÎˢС£Í¨³£Çé¿öÏ£¬ÓжàÉÙ¸ö²åÈëÓï¾ä¾Í»áÓжàÉÙ´ÎË÷Òý»º³åÇøˢС£Èç¹ûÄã¿ÉÒÔÓÃÒ»¸ö²åÈëÓï¾äʵÏÖËùÓÐÐеIJåÈ룬ÔòÎÞÐèʹÓÃÏÔʽËø¶¨Óï¾ä¡£
ÒªÏë¸ü¿ìµØ¶ÔÊÂÎñÐͱí²åÈ룬ÄãÓ¦¸ÃʹÓÃSTART TRANSACTIONºÍCOMMITÓï¾ä£¬¶ø²»ÊÇLOCK TABLESÓï¾ä¡£
Ïà¹ØÎĵµ£º
Ò»¡¢ÊÂÎñ´¦Àí£¨myisamÒýÇæ²»Ö§³ÖÊÂÎñ£¬innodbÒýÇæÖ§³ÖÊÂÎñ£©
£¨1£©start transaction
£¨2£©commit
£¨3£©rollback£¬rollback to [savepoint name]
£¨4£©savepoint [savepoint name]
£¨5£©set autocommit=0 or 1
£¨6£©release savepoint [savepoint name]
×¢Ò⣺create¡¢dropµÈ²Ù×÷£¬²»ÄÜ»ØÍË
¶þ¡¢×Ö·û¼¯
1.×Ö·û±àÂë ......
ʹÓÃant¹¤¾ß±àÒë³ÌÐò£¬ÔËÐгÌÐò.ÃüÁî:ant -f xxx.xmlÖ¸¶¨Éú³ÉÎļþ£»ant run±àÒë²¢ÔËÐÐÎļþ¡£
Èç¹ûHibernate½«ÖÐÎIJåÈëmysqlÊý¾Ý¿â£¬µ÷ÓÃselectÓï¾äÖÐÎÄÏÔʾÂÒÂ룬ÔòmysqlµÄ±àÂ뷽ʽÉèΪgbk£¬×¢ÒâÕâÀïÊÇСд£¬²»ÓÃÖØа²×°mysqlÊý¾Ý¿â£¬½«MySQL Server 5.1Ŀ¼ÏµÄmy.iniÅäÖÃÎļþÀïµÄËùÓÐdefault-character-setÉèΪgbk£¬× ......
1.ÆÕͨlog
¼Ç¼ËùÓÐsql²Ù×÷£¬°üÀ¨select£¬showÓï¾ä¡£
ÉèÖÃ
ĬÈÏÊDz»´ò¿ª´Ëlog¡£
´ò¿ªÊ±¿ÉÒÔÖ¸¶¨Ä¿Â¼£¬²»Ö¸¶¨Ê±±£´æÔÚÊý¾Ý¿â¼Ŀ¼Ï¡£
[mysqld]
log = /data/logs/mysql.log #´Ë·½Ê½ÎªÖ¸¶¨Îļþ
log = 1 ......
LOAD DATA INFILE
ÕâÊÇÎÒÃÇÒª½éÉܵÄ×îºóÒ»¸öµ¼ÈëÊý¾Ýµ½MySQLÊý¾Ý¿âÖеķ½·¨¡£Õâ¸öÃüÁîÓëmysqlimport·Ç³£ÏàËÆ£¬µ«Õâ¸ö·½·¨¿ÉÒÔÔÚmysqlÃüÁîÐÐÖÐʹÓá£Ò²¾ÍÊÇ˵Äú¿ÉÒÔÔÚËùÓÐʹÓÃAPIµÄ³ÌÐòÖÐʹÓÃÕâ¸öÃüÁʹÓÃÕâÖÖ·½·¨£¬Äú¾Í¿ÉÒÔÔÚÓ¦ÓóÌÐòÖе¼ÈëÄúÏëÒªµ¼ÈëµÄÊý¾Ý¡£ ʹÓÃÕâ¸öÃüÁî֮ǰ£¬mysqld½ø³Ì£¨·þÎñ£©±ØÐëÒѾÔÚÔËÐ ......
1.¼ì²éÒÔÇ°°²×°µÄMySQL,жÔØ¡£
rpm -qa|grep -i mysql
rpm -e XXXXX
×¢Èç¹û³öÏÖÁ½ÌõÏàͬµÄ£¬ÔòʹÓÃrpm -e --allmatches
2.°²×°rpm°ü¡£
rpm -ivh MySQL-server-community-5.1.37-0.rhel5.x86_64.rpm
rpm -ivh MySQL-shared-community-5.1.37-0.rhel5.x86_64.rpm
rpm -ivh MySQL-devel-community-5.1.37-0.rhel5.x86_6 ......