Mysql Âý²éѯÆôÓÃ
MySQLÂý²éѯ¼Ç¼ÈÕÖ¾¶ÔÓÚ¸ú×ÙMySQL¸ºÔص÷ÓÅÎÊÌâºÜÓÐÓô¦£¬ÆäʵÆôÓÃMySQLµÄÂý²éѯÈÕÖ¾ºÜ¼òµ¥,Ö»ÐèÒªÔÚMySQLµÄÅäÖÃÎļþÀïÌí¼Ólog-slow-queriesºÍlong_query_timeÁ½¸ö²ÎÊý¼´¿É¡£
WindowsÏ¿ªÆôMySQLÂý²éѯ
MySQLÔÚWindowsϵͳÖеÄÅäÖÃÎļþÒ»°ãÊÇÊÇmy.iniÕÒµ½[mysqld]ÏÂÃæ¼ÓÉÏ
log-slow-queries = F:\MySQL\log\mysqlslowquery.log
long_query_time = 2
LinuxÏÂÆôÓÃMySQLÂý²éѯ
MySQLÔÚWindowsϵͳÖеÄÅäÖÃÎļþÒ»°ãÊÇÊÇmy.cnfÕÒµ½[mysqld]ÏÂÃæ¼ÓÉÏ
log-slow-queries=/data/mysqldata/slowquery.loglong_query_time=2
×¢Òâ
log-slow-queries = F:\MySQL\log\mysqlslowquery.logΪÂý²éѯÈÕÖ¾´æ·ÅµÄλÖã¬
Ò»°ã¶¼½«Õâ¸öĿ¼ÉèÖÃΪMySQLµÄÊý¾Ý´æ·ÅĿ¼£»
long_query_time=2ÖеÄ2±íʾ²éѯ³¬¹ýÁ½Ãë²Å¼Ç¼£»
ÁíÍâ:
ÔÚmy.cnf»òÕßmy.iniÖÐÌí¼Ólog-queries-not-using-indexes²ÎÊý£¬±íʾ¼Ç¼ÏÂûÓÐʹÓÃË÷ÒýµÄ²éѯ¡£±ÈÈ磺
Ïà¹ØÎĵµ£º
Ò»¸ömysqlµÄÁªºÏ²éѯÁÐ×Ó£¬ºÜ»ù±¾µÄ£¬²»¹ýºÜʵÓá£
ÏÈ¿´Êý¾Ý±í¡£Êý¾Ý±íclass£º
-------------------------------
id cname
-------------------------------
1 ÄÐ×°
2 ŮƤ¿ã
3 Å®²ÊÃÞ
-------------------------------
class±í´æ·ÅµÄÊDzúÆ·µÄ´óÀàà ......
±à¼my.cnfÎļþ£¬¼ÓÈ룺
log-slow-queries[=file] #ĬÈÏΪdataĿ¼ÏµÄhostname-slow.logÎļþ
long_query_time=10 (seconds) #Âý²éѯµÄthreshold
log-queries-not-using-indexes #¼Ç¼²»Ê¹ÓÃË÷ÒýµÄ²éѯ
mysqldumpslowÃüÁî»ñµÃÈÕÖ¾ÖÐÏÔʾµÄ²éѯժҪÀ´´¦ÀíÂý²éÑ¯È ......
1¡¢LinuxÏÂmysql°²×°ÍêºóÊÇĬÈÏ£ºÇø·Ö±íÃûµÄ´óСд£¬²»Çø·ÖÁÐÃûµÄ´óСд£»
2¡¢ÓÃrootÕʺŵǼºó£¬ÔÚ/etc/my.cnf ÖеÄ[mysqld]ºóÌí¼ÓÌí¼Ólower_case_table_names=1£¬ÖØÆôMYSQL·þÎñ£¬ÕâʱÒÑÉèÖóɹ¦£º²»Çø·Ö±íÃûµÄ´óСд£»
lower_case_table_names²ÎÊýÏê½â£º
lower_case_table_names = 0
ÆäÖÐ 0£ºÇø·Ö´óСд£¬1 ......
Æô¶¯£º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;
¡¡¡¡Æ¥Åä× ......