Home > Database > Mysql Tutorial > mysql慢查询日志(slow_query_log_file)切换_MySQL

mysql慢查询日志(slow_query_log_file)切换_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 13:31:47
Original
887 people have browsed it

bitsCN.com

mysql慢查询日志(slow_query_log_file)切换

 

slow_query_log_file日志变得很大,对它进项分析变得很不方便,我们就想按天每天产生一个slow_query_log_file文件,每天分析这个日志文件。如何按天切割呢?我们想到了这么一个办法,把日志格式切换成这种形式的hostname-slow_日期.log 这种形式,默认格式为hostname-slow.log。那么如何实现呢?其实很简单。利用mysql默认命令就可以了

 

mysql> show variables like '%query%log%'; +---------------------+----------------------------------------+| Variable_name       | Value                                  |+---------------------+----------------------------------------+| slow_query_log      | OFF                                    | | slow_query_log_file | /usr/local/mysql/data/aeolus1-slow.log | +---------------------+----------------------------------------+mysql> set global slow_query_log_file='/usr/local/mysql/data/aeolus1-slow_2013-07-19.log' ;Query OK, 0 rows affected (0.03 sec)mysql> show variables like '%query%log%';+---------------------+---------------------------------------------------+| Variable_name       | Value                                             |+---------------------+---------------------------------------------------+| slow_query_log      | ON                                                | | slow_query_log_file | /usr/local/mysql/data/aeolus1-slow_2013-07-19.log | +---------------------+---------------------------------------------------+2 rows in set (0.01 sec)
Copy after login

 

ok,设置成功。思路就是这样的

 

写个shell小脚本,定义好时间,这样就可以按天生成日志了。

bitsCN.com
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template