相关文章推荐
有情有义的汤圆  ·  500 Server Error for ...·  3 月前    · 
叛逆的沙滩裤  ·  Solved: Services in ...·  6 月前    · 
含蓄的鞭炮  ·  航班显示屏·  6 月前    · 
You will need to modify the /etc/logrotate.d/mysql file


# The log file name and location can be set in
# /etc/my.cnf by setting the "log-error" option
# in [mysqld]  section as follows:
#
# [mysqld]
# log-error=/var/log/mysqld.log
#
# For the mysqladmin commands below to work, root account
# password is required. Use mysql_config_editor(1) to store
# authentication credentials in the encrypted login path file
# ~/.mylogin.cnf
#
# Example usage:
#
#  mysql_config_editor set --login-path=client --user=root --host=localhost --password
#
# When these actions has been done, un-comment the following to
# enable rotation of mysqld's log error.
#

#/var/log/mysqld.log {
#        create 640 mysql mysql
#        notifempty
#        daily
#        rotate 5
#        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
#}


You will need to uncomment everything below the "# enable rotation of mysqld's log error" line and add the following "--defaults-extra-file=/root/.my.cnf" after /usr/bin/mysqladmin

So it looks something like this:


# The log file name and location can be set in
# /etc/my.cnf by setting the "log-error" option
# in [mysqld]  section as follows:
#
# [mysqld]
# log-error=/var/log/mysqld.log
#
# For the mysqladmin commands below to work, root account
# password is required. Use mysql_config_editor(1) to store
# authentication credentials in the encrypted login path file
# ~/.mylogin.cnf
#
# Example usage:
#
#  mysql_config_editor set --login-path=client --user=root --host=localhost --password
#
# When these actions has been done, un-comment the following to
# enable rotation of mysqld's log error.
#

/var/log/mysqld.log {
create 640 mysql mysql
notifempty
daily
rotate 5
missingok
compress
postrotate
# just if mysqld is really running
if test -x /usr/bin/mysqladmin && \
/usr/bin/mysqladmin --defaults-extra-file=/root/.my.cnf ping &>/dev/null
then
/usr/bin/mysqladmin --defaults-extra-file=/root/.my.cnf  flush-logs
fi
endscript
}

In this file /usr/bin/mysqladmin uses roots password set in .my.cnf. You may need to use ls -la in the /root folder to see this file.

It is possible that this file may not exist on a software install and may need to be created.  You would need to change the password to the password used by your root MySQL user.


# ls -la
-rw-r--r--  1 root root    25 Oct 12  2018 .my.cnf

# cat .my.cnf
[client]
password=7layer