Monday, July 15, 2019

Enable MySQL Log Rotation on CentOS 6.6

Create /root/.my.cnf configuration file with the following content

Content:
[mysqladmin]
password = <password>
user= root

Change the access permissions

chmod 600 /root/.my.cnf


Create mysql file under /etc/logrotate.d (Or edit file if exists)

vim /etc/logrotate.d/mysql 

Content:

/var/log/mysqld/*.log {
        # create 600 mysql mysql
        notifempty
    daily
        rotate 30
        missingok
        compress
        postrotate
    # just if mysqld is really running
    if test -x /usr/bin/mysqladmin && \
       /usr/bin/mysqladmin ping &>/dev/null
    then
       /usr/bin/mysqladmin  flush-general-log flush-slow-log flush-error-log
    fi
    endscript
}





Debug:

logrotate -df /etc/logrotate.d/mysql

Try:

logrotate -df /etc/logrotate.d/mysql



Ref:









No comments:

Post a Comment