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

¹ØÓÚMySQLµÄÂýÈÕÖ¾·ÖÎö¹¤¾ß

½ñÌìÎÒÃÇ¿´¿´¹ØÓÚMySQLÂýÈÕÖ¾µÄÔĶÁ¡£
ÎÒÃÇÖªµÀ£¬Èç¹ûÎÒÃǵÄÓï¾ä²»¹»ÓÅ»¯£¬ÄÇôÊ×ÏÈMySQLµÄÂýÈÕÖ¾ÊǽøÒ»²½ÓÅ»¯µÄÀëÏßÖ¤¾Ý£¬ËäÈ»ÀïÃæÓкÃ
¶à“αÂýÓï¾ä”£¡
ÏȲ»ËµÔõôÓÅ»¯£¬Èç¹ûÄãµÄÈÕÖ¾ÓÐÒ»ÌõÓï¾ä¶ÄסÁË£¬ÄÇô»áÓв»¼ÆÆäÊýµÄÂýÓï¾äÌî³äµ½MySQLµÄÂúÈÕÖ¾ÀïÃæ¡£ÄÇôÊ×ÏÈÌáÁ¶³öÕâЩÓï
¾ä¾Í·Ç³£Í·ÌÛ¡£
½ñÌìÖ÷Òª½éÉÜÁ½ÖÖ¹¤¾ß£º
1,mysqldumpslow¡££¨ÔÛÃÇ
MySQL×Ô´øµÄ¼òµ¥¶øÓÖʵÓõŤ¾ß£©
ÎÒÃÇÏÈÀ´¿´ÏÂmysqldumpslowµÄ½á¹û¡£
[root@localhost ~]# mysqldumpslow -r
localhost-slow.log
Reading
mysql slow query log from localhost-slow.log
Count: 2  Time=7.00s (14s)  Lock=0.00s (0s)  Rows=0.0 (0),
root[root]@localhost
  select * from t_page_sample order by id desc limit N,N
Count: 1  Time=11.00s (11s)  Lock=0.00s (0s)  Rows=1.0 (1),
root[root]@localhost
  select count(*) from t_page_sample
Count: 1  Time=1418.00s (1418s)  Lock=0.00s (0s)  Rows=0.0 (0),
root[root]@localhost
  insert ignore into t_page_sample select ceil(rand()*N),
ceil(rand()*N), date_sub(now(),interval floor(rand()*N) day), now() from
t_page_sample
±ÈÈçÒª²éÕÒÅÅÐòµÄÂýÓï¾ä£º
[root@localhost
~]# mysqldumpslow -r -g "order by " localhost-slow.log
Reading mysql slow query log from
localhost-slow.log
Count: 2 
Time=7.00s (14s)  Lock=0.00s (0s)  Rows=0.0 (0), root[root]@localhost
 
select * from t_page_sample order by id desc limit N,N
×Ô
´øµÄmysqldumpslow¼òµ¥ÊµÓã¬×÷ΪÎÒ¸öÈ˵ÄÊ×Ñ¡¡£¹ØÓÚ¾ßÌåµÄ²ÎÊýº¬Ò壬¿ÉÒԲμûËü×ÔÉíµÄHELP¡£
2,mk-query-digest¡£(Íø
ÉÏÖøÃûµÄ¿ªÔ´½Å±¾¼Ò×åMaatkitÖÐÒ»Ô±)
ÊÖ²áµØÖ·£ºhttp://www.maatkit.org/doc/mk-
query-digest.html
ÏÂÔØ·½·¨£ºwget
http://www.maatkit.org/get/mk-query-digest
ÍêÁ˸³¸øËü¿ÉÖ´ÐÐȨÏÞ¾ÍOK¡£
mk-query-digest
¹¦ÄÜÌ«¶à£¬ÎÒ½ñÌìÖ»ÊÇÊÔÁËÏÂËü¶ÔMySQLÂýÈÕÖ¾µÄ·ÖÎö¹¦ÄÜ¡£
ÒÔÏÂÊÇÎÒ¾õµÃ±È½ÏʵÓõŦÄÜ¡£
1£©·ÖÎöÂýÈÕÖ¾²¢ÇÒ°ÑÕÒ³öÀ´µÄÓï¾äдµ½¹æ¶¨µÄ
±íÀï¡£
[root@localhost ~]#
./mk-query-digest --limit 2 --select
Query_time,Lock_time,Rows_sent,Rows_examined,ts --create-review-table


Ïà¹ØÎĵµ£º

Á¬½ÓMysqlÊý¾Ý¿âС³£Ê¶

1.¼ÓÔØmysqlÇý¶¯°üProperties->java Build Path->Libraries->Add External JARs...
2.Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/Êý¾Ý¿âÃû?user=root&password=ÃÜÂë"); ......

(תÔØ)MySQLÖÐUNIONºÍUNION ALLµÄÇø±ð


ÔÚÊý¾Ý¿â
ÖУ¬UNION
ºÍUNION
ALL
¹Ø¼ü×Ö¶¼Êǽ«Á½¸ö½á¹û¼¯ºÏ²¢ÎªÒ»¸ö£¬µ«ÕâÁ½Õß´ÓʹÓúÍЧ
ÂÊÉÏÀ´Ëµ¶¼ÓÐËù²»Í¬¡£
MySQL
ÖÐ
µÄUNION
UNIONÔÚ½øÐбíÁ´½Óºó»áɸѡµôÖظ´µÄ¼Ç¼£¬ËùÒÔÔÚ±íÁ´½Óºó»á¶ÔËù²úÉúµÄ½á¹û¼¯½øÐÐÅÅÐòÔËË㣬ɾ³ýÖظ´µÄ¼Ç¼ÔÙ
·µ»Ø½á¹û¡£Êµ¼Ê´ó²¿·ÖÓ¦ÓÃÖÐÊDz»»á²úÉúÖظ´µÄ¼Ç¼£¬×î³£¼ûµÄÊǹý³Ì± ......

apacheµÄ¾²Ì¬/¶¯Ì¬±àÒëÔÚapache+php+mysqlµÄÓ¦ÓÃ

apacheµÄ¾²Ì¬/¶¯Ì¬±àÒëÔÚapache+php+mysqlµÄÓ¦ÓÃ
ÎÒÏë´ó¼ÒÓв»ÉÙ¶¼³É¹¦ÊµÏÖapache+php+mysql£¬ÍøÉϵÄÎÄÕÂÒ²Óв»ÉÙ£¬µ«ÎÒ·¢ÏÖ²»ÉÙÎÄÕ¶¼Êdz­À´³­È¥£¬²¢ÇÒ
ûÓÐ˵Ã÷°×±àÒëµÄ·½Ê½£¬ÓеÄË÷ÐÔapache1.3µÄ±àÒë·½·¨Ô­·â²»¶¯µÄ°á¹ýÀ´Ì×ÔÚapache2.0£¬ÏÔÈ»Îóµ¼Ò»Ð©²ËÄñ £¡
ÎÒ½ñÌì¾ÍÒÔapache+mysql+php˵һϾ²Ì¬±àÒëºÍDSO¶¯Ì¬±à ......

MySQL ÃüÁîÐÐ ÖÐÎÄÂÒÂë

Óöµ½Ò»¸öÎÊÌâÊÇÔÚMySQLÃüÁîÐвåÈëÖÐÎÄÊý¾Ý»òÕß²éѯÖÐÎÄÊý¾Ýʱ³öÏÖÂÒÂ룬»òÕßÏÔʾ²»¶Ô¡£
 
ÔÚÃüÁîÐÐÊäÈë:show variables like ‘character_set_%’;
 
²é¿´µ±Ç°ÅäÖõıàÂ룻
 
 
ÔÚÃüÁîÐÐÊäÈë :set names utf8;
ÔòµÈͬÓÚ
set character_set_client=utf8;
set character_set_results ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ