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

ÓÃmysqldumpslow·ÖÎömysqlµÄslow query log

mysqlÓÐÒ»¸ö¹¦ÄܾÍÊÇ¿ÉÒÔlogÏÂÀ´ÔËÐеıȽÏÂýµÄsqlÓï¾ä£¬Ä¬ÈÏÊÇûÓÐÕâ¸ölogµÄ£¬ÎªÁË¿ªÆôÕâ¸ö¹¦ÄÜ£¬
ÒªÐÞ¸Ämy.cnf»òÕßÔÚmysqlÆô¶¯µÄʱºò¼ÓÈëһЩ²ÎÊý¡£Èç¹ûÔÚmy.cnfÀïÃæÐ޸ģ¬ÐèÔö¼ÓÈçϼ¸ÐÐ
long_query_time = 1
log-slow-queries = /var/youpath/slow.log
log-queries-not-using-indexes
long_query_time ÊÇÖ¸Ö´Ðг¬¹ý¶à¾ÃµÄsql»á±»logÏÂÀ´£¬ÕâÀïÊÇ1Ãë¡£
log-slow-queries ÉèÖðÑÈÕ־дÔÚÄÇÀ¿ÉÒÔΪ¿Õ£¬ÏµÍ³»á¸øÒ»¸öȱʡµÄÎļþhost_name-slow.log£¬
log-queries-not-using-indexes ¾ÍÊÇ×ÖÃæÒâ˼£¬logÏÂÀ´Ã»ÓÐʹÓÃË÷ÒýµÄquery¡£
°ÑÉÏÊö²ÎÊý´ò¿ª£¬ÔËÐÐÒ»¶Îʱ¼ä£¬¾Í¿ÉÒԹصôÁË¡£
½ÓÏÂÀ´¾ÍÊÇ·ÖÎöÁË£¬ÕâÀïµÄÎļþÃû×Ö½Ðhost-slow.log¡£
ÏÈmysqldumpslow –helpÒÔÏ£¬eËüÖ÷ÒªÓõÄÊÇ
-s ORDER what to sort by (t, at, l, al, r, ar etc), ‘at’ is default
-t NUM just show the top n queries
-g PATTERN grep: only consider stmts that include this string
-s£¬ÊÇorderµÄ˳Ðò£¬ËµÃ÷дµÄ²»¹»Ïêϸ£¬Ö÷ÒªÓÐ
c,t,l,rºÍac,at,al,ar£¬·Ö±ðÊÇ°´ÕÕquery´ÎÊý£¬Ê±¼ä£¬lockµÄʱ¼äºÍ·µ»ØµÄ¼Ç¼ÊýÀ´ÅÅÐò£¬Ç°Ãæ¼ÓÁËaµÄʱµ¹Ðð
-t£¬ÊÇtop nµÄÒâ˼£¬¼´Îª·µ»ØÇ°Ãæ¶àÉÙÌõµÄÊý¾Ý
-g£¬ºó±ß¿ÉÒÔдһ¸öÕýÔòÆ¥Åäģʽ£¬´óСд²»Ãô¸ÐµÄ
mysqldumpslow -s c -t 20 host-slow.log
mysqldumpslow -s r -t 20 host-slow.log
ÉÏÊöÃüÁî¿ÉÒÔ¿´³ö·ÃÎÊ´ÎÊý×î¶àµÄ20¸ösqlÓï¾äºÍ·µ»Ø¼Ç¼¼¯×î¶àµÄ20¸ösql¡£
mysqldumpslow -t 10 -s t -g “left join” host-slow.log
Õâ¸öÊÇ°´ÕÕʱ¼ä·µ»ØÇ°10ÌõÀïÃ溬ÓÐ×óÁ¬½ÓµÄsqlÓï¾ä¡£
ÓÃÁËÕâ¸ö¹¤¾ß¾Í¿ÉÒÔ²éѯ³öÀ´ÄÇЩsqlÓï¾äÊÇÐÔÄܵÄÆ¿¾±£¬½øÐÐÓÅ»¯£¬±ÈÈç¼ÓË÷Òý£¬¸ÃÓ¦ÓõÄʵÏÖ·½Ê½µÈ¡£ 


Ïà¹ØÎĵµ£º

Nagios£º¼à¿ØMysql·þÎñÆ÷

ʱ¼ä£º2009-03-12 12:38:24  À´Ô´£ºLinuxÁªÃË
  ×÷Õߣº
 À´Ô´£ºit168.com
   
    ×÷ÕߣºÌïÒÝ(sery@163.com)
    Ë×»°Ëµ£º¹¤ÓûÉÆÆäÊ£¬±ØÏÈÀûÆäÆ÷.Òª×öºÃϵͳ¹ÜÀí,ʹ×Ô¼ºµÄ¹¤×÷¸üÇáËɸüÓÐЧµÄ»°£¬Ò»¸öºÃµÄ¼à¿Ø¹¤¾ßÊDZز»¿ÉÉÙµÄÁË¡£ÔÚÕâÀïÎÒÏò ......

mysqlµÄCR_COMMANDS_OUT_OF_SYNC´íÎó

mysqlÖ´ÐÐsqlÓï¾äʱÓÐʱ»á³öÏÖCR_COMMANDS_OUT_OF_SYNC´íÎó£¨2014£©
ÌáʾÓïΪ
commands out of sync; you can't run this command now
ÍøÉ϶Դ˴íÎóµÄÃèÊöºÜÉÙ£¬¶øÇÒûÓиø³ö½â¾ö·½·¨¡£
ÆäʵÕâÊÇÒòΪÉÏÒ»¸ösqlÖ´Ðзµ»ØÁ˶à¸ö½á¹û¼¯£¬µ«Ã»Óаѽá¹û¶¼È¡³öÀ´£¬¾ÍÖ´ÐÐÁËеÄsqlÓï¾ä£¬¾Í»á²úÉúÕâ¸ö´íÎó¡£
Ó¦ÔÚsqlÓï¾äÖ´Ðкó ......

mysqlÃüÁî´óÈ«

Æô¶¯£ºnet start mySql;
¡¡¡¡½øÈ룺mysql -u root -p/mysql -h localhost -u root -p databaseName;
¡¡¡¡ÁгöÊý¾Ý¿â£ºshow databases;
¡¡¡¡Ñ¡ÔñÊý¾Ý¿â£ºuse databaseName;
¡¡¡¡Áгö±í¸ñ£ºshow tables£»
¡¡¡¡ÏÔʾ±í¸ñÁеÄÊôÐÔ£ºshow columns from tableName£»
¡¡¡¡½¨Á¢Êý¾Ý¿â£ºsource fileName.txt;
¡¡¡¡Æ¥Åä× ......

MySql ³£¼ûÒì³£


1016´íÎó£ºÎļþÎÞ·¨´ò¿ª£¬Ê¹Óúǫ́ÐÞ¸´»òÕßʹÓÃphpmyadmin½øÐÐÐÞ¸´¡£
1044´íÎó£ºÊý¾Ý¿âÓû§È¨ÏÞ²»×㣬ÇëÁªÏµ¿Õ¼äÉ̽â¾ö
1045´íÎó£ºÊý¾Ý¿â·þÎñÆ÷/Êý¾Ý¿âÓû§Ãû/Êý¾Ý¿âÃû/Êý¾Ý¿âÃÜÂë´íÎó£¬ÇëÁªÏµ¿Õ¼äÉ̼ì²éÕÊ»§¡£
1054´íÎ󣺳ÌÐòÎļþ¸úÊý¾Ý¿âÓгåÍ»£¬ÇëʹÓÃÕýÈ·µÄ³ÌÐòÎļþÉÏ´«ÉÏÈ¥¸²¸Ç¡£
1146´íÎó£ºÊý¾Ý±íȱʧ,Çë»Ö ......

mysql ±íÊý¾Ý±¸·ÝºÍ»Ö¸´

 
¼Ù¶¨±ítbl_name¾ßÓÐÒ»¸öPRIMARY KEY»òUNIQUEË÷Òý£¬±¸·ÝÒ»¸öÊý¾Ý±íµÄ¹ý³ÌÈçÏ£º
1¡¢Ëø¶¨Êý¾Ý±í£¬±ÜÃâÔÚ±¸·Ý¹ý³ÌÖУ¬±í±»¸üÐÂ
mysql>LOCK
TABLES READ tbl_name;
¹ØÓÚ±íµÄËø¶¨µÄÏêϸÐÅÏ¢£¬½«ÔÚÏÂÒ»Õ½éÉÜ¡£
2¡¢µ¼³öÊý¾Ý
mysql>SELECT
* INTO OUTFILE ‘tbl_name.bak’ from tbl_name;
3¡¢½âË ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ