当前位置:  数据库>mysql

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

    来源: 互联网  发布时间:2014-10-13

    本文导语:  1, see the slow log status; mysql> show variables like '%slow%';+---------------------+------------------------------------------+| Variable_name       | Value                                    |+---------------------+--------------------------------------...

1, see the slow log status;

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)

2, stop the slow log server.

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)

mysql>
mysql> show variables like '%slow%'; -- check slow log status
+---------------------+------------------------------------------+
| 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)

3, reset the new path of slow log

mysql> set global slow_query_log_file='/mysqllog/slow_log/slow_queries_3306_new.log';
Query OK, 0 rows affected (0.03 sec)

4, start the slow log server

mysql>
mysql>
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)

5, check the slow sql in the new slow log file.

mysql> select sleep(10) as a, 1 as b;
+---+---+
| a | b |
+---+---+
| 0 | 1 |
+---+---+
1 row in set (10.00 sec)

mysql>
[mysql@xxx-xxx ~]$ more /mysqllog/slow_log/slow_queries_3306_new.log
......
Time                 Id Command    Argument
# Time: 140213  6:44:24
# User@Host: root[root] @ localhost []
# Query_time: 10.000365  Lock_time: 0.000000 Rows_sent: 1  Rows_examined: 0
SET timestamp=1392273864;
select sleep(10) as a, 1 as b;

6, backup the old big slow log file to other directory.

mv /mysqllog/slow_log/slow_queries_3306.log /mysqlbackup/slow_log/slow_queries_3306.log.bak.20140213


    
 
 
 
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐
  • 测试php连接mysql是否成功的代码分享
  • 解决MySQL Workbench gnome-keyring-daemon错误的方法分享
  • mysql字符集和数据库引擎修改方法分享
  • 还原大备份mysql文件失败的解决方法分享
  • 彻底卸载MySQL的方法分享
  • centos中mysql备份数据库脚本分享
  • python文件读写并使用mysql批量插入示例分享(python操作mysql)
  • 强制修改mysql的root密码的六种方法分享(mysql忘记密码)
  • mysql 表维护与改造代码分享
  • mysql筛选GROUP BY多个字段组合时的用法分享
  • 磁盘已满造成的mysql启动失败问题分享
  • 貌似很强的mysql备份策略分享
  • MySQL Order By用法分享
  • aspx中的mysql操作类sqldatasource使用示例分享
  • xampp中修改mysql默认空密码(root密码)的方法分享
  • mysql数据库备份命令分享(mysql压缩数据库备份)
  • mysql中合并两个字段的方法分享
  • 分享MYSQL插入数据时忽略重复数据的方法
  • 在linux中导入sql文件的方法分享(使用命令行转移mysql数据库)
  • 关于mysql中innodb的count优化问题分享
  • mysql中如何查看最大连接数(max_connections)和修改最大连接数
  • mysql筛选GROUP BY多个字段组合时的用法分享 iis7站长之家
  • Mysql查询错误:ERROR:no query specified原因
  • MySQL 重装MySQL后, mysql服务无法启动
  • php安装完成后如何添加mysql扩展
  • 为什么用linux安装盘安装了mysql后,启动mysql,提示找不到mysql.sock文件?
  • mysql中查询当前正在运行的SQL语句并找出mysql中运行慢的sql语句
  • 請教,在redhat linux7.2+mysql 中,系統提示mysql已啟動,網頁卻不能訪問mysql?
  • Myeclipse中自带Tomcat的JDBC连接池配置(mysql和mssql)
  • 求解释: useradd -g mysql mysql -d /home/mysql -s /sbin/nologin
  • MySQL Workbench的下载安装与使用教程


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,,E-mail:www_#163.com(请将#改为@)

    浙ICP备11055608号-3