Home  >  Article  >  Database  >  MySQL automatically records slow query log instances

MySQL automatically records slow query log instances

零下一度
零下一度Original
2017-07-23 13:28:541363browse

Experimental environment:
OS #Modify variables:

show (global) variables like '%slow_query%'

Variables related to slow query log:

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 log

You 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.log
View 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn