Linux enable MySQL slow query
The code is as follows |
Copy Code |
Vim/etc/my.cnf [Mysqld] Slow-query-log = on # Open slow query function Slow_query_log_file =/usr/local/mysql/data/slow-query.log # Slow query log store path and name Long_query_time = 5 # query statement with more than 5s query time ### log-queries-not-using-indexes = on # list query statements that do not use indexes |
windows open MySQL slow query
MySQL in Windows system configuration file is generally My.ini find [mysqld] below plus
The code is as follows |
Copy Code |
Log-slow-queries = F:\MySQL\log\mysqlslowquery.log Long_query_time = 2 |
Add:
Add the Log-queries-not-using-indexes parameter to the MY.CNF or My.ini, which indicates that the query that does not use the index is logged. Like what:
The code is as follows |
Copy Code |
Log-slow-queries=/data/mysqldata/slowquery.log long_query_time=2 Log-queries-not-using-indexes |
Analyze the slow query log tool Mysqlsla This is a very good tool in Linux to help us see some slow query log oh state.
Mysqlsla-lt Slow/var/lib/mysql/slowquery.log