查询是否打开mysql慢查询日志
show variables like ‘slow_query_log’;

show variables like ‘%log%’;
//查看是否记录无索引的sql

//将没有索引的sql记录到日志表
set global log_queries_not_using_indexes =on;
//查询多长时间的sql会记录日志
show variables like ‘long_query_time’

我这里是10秒
//查询慢查询日志存储位置
show variables like ‘slow%’;

//设置日志存储路径
set global slow_query_log_file =’ 修改的路径’
//开启慢查询日志
set global slow_query_log =on;
//查看是否记录上日志
tail -50 修改的路径;
本文详细介绍如何在MySQL中配置慢查询日志,包括显示慢查询日志状态、设置记录未使用索引的SQL、调整慢查询阈值、指定日志文件路径等关键步骤。

6514





