MySQL 性能分析之慢查询日志

MySQL 性能分析 About 710 words

查看是否开启

show variables like 'slow_query_log%';

输出:

mysql> show variables like 'slow_query_log%';
+---------------------+--------------------------------------+
| Variable_name       | Value                                |
+---------------------+--------------------------------------+
| slow_query_log      | OFF                                  |
| slow_query_log_file | /var/lib/mysql/ce2e9ece7dd3-slow.log |
+---------------------+--------------------------------------+
2 rows in set (0.00 sec)

开启慢查询记录

set global slow_query_log='ON';

设置慢查询阈值

默认10秒,单位:秒。

set global long_query_time=1;

设置慢查询记录的文件位置

默认位置:/var/lib/mysql/localhost-slow.log

set global slow_query_log_file='/usr/local/mysql/data/slow.log'; 
Views: 1,358 · Posted: 2022-05-10

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh