MySQL Forums
Forum List  »  MySQL Administrator

Re: mysql_slow_queries.log flush
Posted by: waruna Senavirathna
Date: February 18, 2012 05:47PM

you can use linux logrotate for this

1) first you need to configure my.cnf

# /root/.my.cnf configuration file with the following
# content:
#
# [mysqladmin]
# password = <secret>
# user= root
#
# where "<secret>" is the password.
#
# ATTENTION: This /root/.my.cnf should be readable ONLY
# for root !

2)
open or create /etc/logrotate.d/mysql file
add this line

/var/lib/mysql/*.log {
# create 600 mysql mysql
notifempty
daily
rotate 3
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-logs
fi
endscript
}
#

if you are not configured my.cnf
[mysqladmin]
password = <secret>
user= root
you can add replace "/usr/bin/mysqladmin flush-logs" line like below

/usr/bin/mysqladmin -u<mysql user> -p<mysql user password> flush-logs

3)

logrotate -f /etc/logrotate.d/mysql

Options: ReplyQuote


Subject
Written By
Posted
February 03, 2012 05:51AM
Re: mysql_slow_queries.log flush
February 18, 2012 05:47PM
February 29, 2012 09:24PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.