Mysql slow query log (slow_query_log_file) Switch slow_query_log_file the log becomes very large and it is inconvenient to analyze its input items. We want to generate a slow_query_log_file file every day and analyze the log file every day. How to cut by day? We have come up with such a way to switch the log format to this form of hostname-slow _ date. log, the default format is hostname-slow.log. So how to implement it? It is actually very simple. Use the default mysql command.
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)
OK. The setting is successful. The idea is to write a shell script and define the time so that logs can be generated by nature.