Mysql slow query log (slow_query_log_file) Switch

Source: Internet
Author: User
Tags mysql slow query log

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.