MySQL Slow query log segmentation

Source: Internet
Author: User
Tags mysql slow query log

mysql> set global slow_query_log=0; Query OK, 0 rows Affected (0.00 sec)  mysql> set global slow_query_log_file= '/data/mysql_33096/mysqllog/slow_ Query_2014-06-09.log '; Query OK, 0 rows Affected (0.00 sec)  mysql> Show variables like ' slow% '; +---------------------+----------------- -------------------------------------+| variable_name | Value |+---------------------+------------------------------------------------------+| Slow_launch_time | 2 | | Slow_query_log | OFF | | Slow_query_log_file | /data/mysql_33096/mysqllog/slow_query_2014-06-09.log |+---------------------+---------------------------------- --------------------+ mysql> set global slow_query_log=1; Query OK, 0 rows Affected (0.00 sec) mysql> Show variables like ' slow% '; +---------------------+----------------------- --------------------+| variable_name | Value |+---------------------+-------------------------------------------+| Slow_launch_time | 2 | | Slow_query_log | On | | Slow_query_log_file | /data/mysql_33096/mysqllog/slow_query.log |+---------------------+-------------------------------------------+3 rows in Set ( 0.00 sec)   /root/slowlog.sh script #!/bin/bash### #split mysql slow-query-log###### #LOGDIR =/data/mysqllogdate= ' date + '%y-%m-%d ' user=xxxpasswd=**** #stop slow_query_logmysql-u$user-p$passwd-e "set global slow_query_log=0" #reset the filename of SLO W_QUERY_LOGMYSQL-U$USER-P$PASSWD-E "Set global slow_query_log_file= ' ${logdir}/slow_query_${date}.log '" #enable slow _QUERY_LOGMYSQL-U$USER-P$PASSWD-E "Set global slow_query_log=1" #remove slow_query_log 7days ago.cd $LOGDIRfind./slow_ query*-ctime +7-exec rm-f {} \; Timed tasks: [[email protected] home]$ sudo crontab-e00 0 * * */root/slowlog.sh

MySQL Slow query log segmentation

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.