MySQL Slow check log

Source: Internet
Author: User

To view the current slow-scan log status:

Show variables like '%slow% '; #主要关注三个变量: Slow_query_log #是否启用slow_query_log_file #日志文件 # time threshold for slow check show variables like ' Long_ Query_time ';


To configure the Enable slow scan log:
# # Vim My.cnf:slow_query_log=1slow_query_log_file=/var/log/mysql/slow.log #需要新建该文件, and note the file's read and Write permissions long_query_time = 2## You can switch configuration under current connection, Mysql Shell execution: Set long_query_time = 5 #临时调整当前连接慢查询的阈值, does not affect other connection thresholds set global slow_query_log=0 #全局关闭 slow log. (MySQL enforces this as a global configuration) #关闭状态持续至手动切回开启


To view the slow-scan log:

The way to view log files directly is laborious, but MySQL provides simple log analysis tools Mysqldumpslow

Mysqldumpslow "Options" log_file option:-S order #以什么排序 (Al, at, AR, AE, C, L, R, E, T) #at (average query time, default), AL (Average lock time), AR (average Off count) #c (Record Count), L (lock time), R (transmission line number), T (query time)-R #倒序-T #显示几条慢查询-G pattern #搜索关键字


MySQL Slow check log

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.