show variables like '%slow_query_log%';
複製代碼
+---------------------+--------------------------------------+
| Variable_name | Value |
+---------------------+--------------------------------------+
| slow_query_log | OFF |
| slow_query_log_file | /var/lib/mysql/9e6bec7d7160-slow.log |
+---------------------+--------------------------------------+
複製代碼
說明: 1開啓;0關閉;mysql
set global slow_query_log = 1;
複製代碼
默認執行時間超過10s纔會被記錄到日誌sql
show variables like '%long_query%';
複製代碼
+-----------------+-----------+
| Variable_name | Value |
+-----------------+-----------+
| long_query_time | 10.000000 |
+-----------------+-----------+
複製代碼
注意:設置後須要從新打開mysql客戶端才能到最新的值spa
set global long_query_time = 0.8;
複製代碼
show variables like "%innodb_print_all_deadlocks%";
複製代碼
+----------------------------+-------+
| Variable_name | Value |
+----------------------------+-------+
| innodb_print_all_deadlocks | OFF |
+----------------------------+-------+
複製代碼
set global innodb_print_all_deadlocks=1
複製代碼