Experimental environment:
OS #Modify variables:
show (global) variables like '%slow_query%'
set global 变量名 = 值
Let’s open the slow query log first:
Modify Query time:
The remaining two global variables, log path and unindexed records, should be the default values. 2. View MySQL slow query logYou can view it directly:
是否开启慢查询日志 slow_query_log = OFF long_query_time = 10 最大时间限制,超过此时间,再记录 slow_query_log_file = /usr/slow.log 日志文件位置 log_queries_not_using_indexes = OFF 没有使用索引的搜索是否记录You can also use
mysqldumpslow
View the slow query log:vim /usr/local/var/mysql/DyanLideMacBook-Air-slow.logView helpmysqldumpslow --help
:
Translate several commonly used ones:
mysqldumpslow -s at -a /usr/local/var/mysql/DyanLideMacBook-Air-slow.log
The above is the detailed content of MySQL automatically records slow query log instances. For more information, please follow other related articles on the PHP Chinese website!