[ 查看系统关于慢查询的设置 ]
mysql> show variables like ‘%slow%‘; +---------------------------+--------------------------------+ | Variable_name | Value | +---------------------------+--------------------------------+ | log_slow_admin_statements | OFF | | log_slow_slave_statements | OFF | | slow_launch_time | 2 | | slow_query_log | OFF | | slow_query_log_file | /data/mysql/localhost-slow.log | +---------------------------+--------------------------------+
[ 开启慢查询日志 ]
// 开启慢查询日志 mysql> set global slow_query_log=on; // 设置慢查询的时间阀值 mysql> set global slow_launch_time=1; // 是定慢查询日志的路径 mysql> set global slow_query_log_file="/tmp/slow.log";
[ 配置文件 ]
[mysqld] slow_launch_time=1 slow_query_log=1 slow_query_log_file=/tmp/slow.log log_throttle_queries_not_using_indexes=1
Mysql 自带日志分析工具 mysqldumpslow
时间: 2024-11-05 16:41:15