rotating mysql slow query log

前端 未结 3 2040
别跟我提以往
别跟我提以往 2021-01-15 02:47

My server\'s MySQL slow query log is growing day by day (37 MB now) so I want to rotate it. If I move current log file to another folder then will MySQL automatically create

3条回答
  •  旧时难觅i
    2021-01-15 03:09

    You can setup a daily cron which will be ziping and emptying the logfile:

    zip /tmp/$(date +%Y-%m-%d)-slow-query-log.zip /var/lib/mysql/slow-queries.log
    cat /dev/null > /var/lib/mysql/slow-queries.log
    

    Of course, if your slow query log has so much content logged every day you (or someone else) ought to investigate and fix the bad queries :)

提交回复
热议问题