MySQL Slow query log script

Source: Internet
Author: User
Tags mysql slow query log

#!/bin/bash

log=/diskb/mysql/slowlog/#定义日志存储路径

Date= ' date + '%y-%m-%d ' #定义时间参数

User=root #填写MySQL账户信息

passwd=123456

MYSQL-U$USER-P$PASSWD-E "Set global slow_query_log=0" #停止mysql慢查询日志

MYSQL-U$USER-P$PASSWD-E "Set global slow_query_log_file= ' ${log}/slow_query_${date}.log '" #按天配置路径

MYSQL-U$USER-P$PASSWD-E "Set global slow_query_log=1" #开启日志

CD $LOG

Find./slow_query*-ctime +7-exec rm-f {} \; #移除七天前日志

This article is from the "Three Fat Technical Blog" blog, please be sure to keep this source http://jinsanpang.blog.51cto.com/2222920/1901203

MySQL Slow query log script

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.