01 Feb

MySQL slow queries log rotation

By default MySQL server doesn’t rotate slow queries log. Probably the simplest way to get rid of slow log which takes gigabytes is to use logrotate. Here’s an example:

[root@marge ~]# cat /etc/logrotate.d/mysql-slow
/var/log/mysqld-slow.log {
weekly
missingok
rotate 1
nocompress
copytruncate
notifempty
create 644 mysql mysql
}
[root@marge ~]#

If you need more than one rotated log adjust rotate values.