[Level 2] Rotate MySQL General Log and Slow Query Log.
By default, general Log and slow query log will not be rotated in MySQL Server. So, we can use "logrotate" on Linux.
All we have to do is to create a file named /etc/logrotate.d/mysqld,
and the setting as following:
The way to test:
Wish this helps.
regards,
Stanley Huang
All we have to do is to create a file named /etc/logrotate.d/mysqld,
and the setting as following:
/var/lib/mysql/mysqld-slow.log /var/lib/mysql/mysqld.log {
weekly
rotate 8
create 0644 mysql mysql
missingok
notifempty
sharedscripts
postrotate
# flush-logs and the MySQL account granted with RELOAD permission
/usr/bin/mysqladmin -uroot -padmin123 flush-logs
endscript
}
rotate 8
create 0644 mysql mysql
missingok
notifempty
sharedscripts
postrotate
# flush-logs and the MySQL account granted with RELOAD permission
/usr/bin/mysqladmin -uroot -padmin123 flush-logs
endscript
}
The way to test:
# logrotate -fv /etc/logrotate.d/mysqld
Wish this helps.
regards,
Stanley Huang
Comments
Post a Comment