Home > Database > Mysql Tutorial > body text

MySQL automatically records slow query log instances

零下一度
Release: 2017-07-23 13:28:54
Original
1361 people have browsed it

Experimental environment:
OS #Modify variables:

show (global) variables like '%slow_query%'
Copy after login

Variables related to slow query log:

set global 变量名 = 值
Copy after login

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
没有使用索引的搜索是否记录
Copy after login

You can also use

mysqldumpslow

View the slow query log:

vim /usr/local/var/mysql/DyanLideMacBook-Air-slow.log
Copy after login
View helpmysqldumpslow --help

Translate several commonly used ones:

mysqldumpslow -s at -a  /usr/local/var/mysql/DyanLideMacBook-Air-slow.log
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!