标签:variable query 路径 开启 net code row like 命名
在日常开发中,为了监控数据库的执行情况,往往我们需要开启慢查询日志。通过检查慢查询日志来确定sql的方向。但是长时间的运行势必导致慢查询日志过大,这种情况就需要将旧的慢查询日志保存起来,然后重新生成一份慢查询日志。
————参考博客:正确安全清空在线慢查询日志slow log的流程
mysql> show variables like '%slow%';
+---------------------+------------------------------------------+
| Variable_name | Value |
+---------------------+------------------------------------------+
| log_slow_queries | ON |
| slow_launch_time | 2 |
| slow_query_log | ON |
| slow_query_log_file | /mysqllog/slow_log/slow_queries_3306.log |
+---------------------+------------------------------------------+
4 rows in set (0.00 sec)
mysql> set global slow_query_log=0;
Query OK, 0 rows affected (0.27 sec)
mysql> show variables like '%slow%';
+---------------------+------------------------------------------+
| Variable_name | Value |
+---------------------+------------------------------------------+
| log_slow_queries | OFF |
| slow_launch_time | 2 |
| slow_query_log | OFF |
| slow_query_log_file | /mysqllog/slow_log/slow_queries_3306.log |
+---------------------+------------------------------------------+
4 rows in set (0.00 sec)
mv slow.log slow.log.01
mysql> set global slow_query_log_file='/mysqllog/slow_log/slow_queries_3306_new.log';
Query OK, 0 rows affected (0.03 sec)
mysql> set global slow_query_log=1;
Query OK, 0 rows affected (0.01 sec)
mysql> show variables like '%slow%';
+---------------------+----------------------------------------------+
| Variable_name | Value |
+---------------------+----------------------------------------------+
| log_slow_queries | ON |
| slow_launch_time | 2 |
| slow_query_log | ON |
| slow_query_log_file | /mysqllog/slow_log/slow_queries_3306_new.log |
+---------------------+----------------------------------------------+
4 rows in set (0.00 sec)
标签:variable query 路径 开启 net code row like 命名
原文地址:https://www.cnblogs.com/mrnx2004/p/11838314.html