mysql> show variables like 'slow_query%';
+---------------------------+----------------------------------+
| Variable_name | Value |
+---------------------------+----------------------------------+
| slow_query_log | OFF |
| slow_query_log_file | /mysql/data/localhost-slow.log |
+---------------------------+----------------------------------+
mysql> show variables like 'long_query_time';
+-----------------+-----------+
| Variable_name | Value |
+-----------------+-----------+
| long_query_time | 10.000000 |
+-----------------+-----------+
2.設(shè)置方法
方法一:全局變量設(shè)置
將 slow_query_log 全局變量設(shè)置為“ON”狀態(tài)
mysql> set global slow_query_log='ON';
設(shè)置慢查詢?nèi)罩敬娣诺奈恢?mysql> set global slow_query_log_file='/usr/local/mysql/data/slow.log';
查詢超過1秒就記錄
mysql> set global long_query_time=1;