How to Enable Slow Query Log in MySQL 5.6

本文介绍如何在MySQL5.6中快速且正确地启用慢查询日志功能,这对于排查应用性能问题非常有用。文章详细说明了通过编辑my.cnf文件来设置long_query_time、slow_query_log及slow_query_log_file参数的方法,并提供了重启MySQL服务的具体步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

How to Enable Slow Query Log in MySQL 5.6

Add Comment

by Santosh Prasad

Compared to previous version in MySQL 5.6 they introduced different way for logging slow queries.

In this article I will show you to quickly and correctly enable the slow query log in MySQL 5.6 which is extremely useful for debugging application performance issues.

 

Enable Slow Query Log in MySQL 5.6

Follow the below steps to enable slow query log in MySQL 5.6.

1. Login to your MySQL server.

2. Open the my.cnf file in your favourite test editor.

# vim /etc/my.cnf

Add the following line in:

long_query_time=1
slow_query_log=1
slow_query_log_file="/var/log/mysql/log-slow-queries.log"

Where;

long_query_time – Defines the minimum threshold for the “slow query” designation.

1 means log all queries that take more than 1s to execute slow_query_log – Value of 1 means enable. 0 means disable slow_query_log_file – Log file path. This path generally be at the same location as mysql-error.log

3. Reload the MySQL server it will not cause an interruption.

# service mysql reload
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值