码迷,mamicode.com
首页 > 其他好文 > 详细

正确安全清空在线慢查询日志slow log的流程

时间:2017-05-06 14:15:37      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:logs   sql   move   log   查看   like   安全   ror   nbsp   

 

查看慢查询日志的状态:

mysql> show variables like ‘%slow%‘;
+---------------------+-----------------------------+
| Variable_name       | Value                       |
+---------------------+-----------------------------+
| log_slow_queries    | ON                          |
| slow_launch_time    | 2                           |
| slow_query_log      | ON                          |
| slow_query_log_file | /data1/mysql/mysql-slow.log |
+---------------------+-----------------------------+
4 rows in set (0.00 sec)

mysql> show variables like ‘%long_query_time%‘;
+-----------------+-----------+
| Variable_name   | Value     |
+-----------------+-----------+
| long_query_time | 10.000000 |
+-----------------+-----------+
1 row in set (0.00 sec)

 先停慢查询功能:

mysql> set global slow_query_log=0;
Query OK, 0 rows affected (0.05 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 | /data1/mysql/mysql-slow.log |
+---------------------+-----------------------------+
4 rows in set (0.00 sec)

重新设置慢查询日志的路径:

mysql> set global slow_query_log_file=‘/data1/mysql/mysql-slow01.log‘;
Query OK, 0 rows affected (0.00 sec)

 开启慢查询工能:

mysql> set global slow_query_log=1;
Query OK, 0 rows affected (0.53 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 | /data1/mysql/mysql-slow01.log |
+---------------------+-------------------------------------------+
4 rows in set (0.00 sec)

 查看生成的慢查询日志:

# ls
cp_aurora    ib_logfile1       mysql-bin.000057  mysql.pid           test
emove        mysql             mysql-bin.000058  mysql-slow01.log    zabbix
ibdata1      mysql-bin.000055  mysql-bin.index   mysql-slow.log
ib_logfile0  mysql-bin.000056  mysql-error.log   performance_schema

 

正确安全清空在线慢查询日志slow log的流程

标签:logs   sql   move   log   查看   like   安全   ror   nbsp   

原文地址:http://www.cnblogs.com/bass6/p/6816331.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!