error: error running shared postrotate script for /var/log/mysql.log /var/log/mysql/mysql.log
run-parts: /etc/cron.daily/logrotate exited with return code 1
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
In Debian, mysql is controlled via the mysql user 'debian-sys-maint'@'localhost'. The password for this user is stored in /etc/mysql/debian.cnf.
Note the password being used in this file. If you have a password for root (like you should), you will need to get into mysql with the following command.
mysql -u root -p
Otherwise, you can just type 'mysql'. In the mysql> prompt, run the following.
GRANT RELOAD, SHUTDOWN, PROCESS, SHOW DATABASES, SUPER, LOCK TABLES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY 'XXXXXXXXXXXX';
Substitute the password found in /etc/mysql/debian.cnf in place of the Xs. And finally...
You should now be able to restart your mysql server with no errors using the command:
However, the restart is not required.
On Ubuntu 18 my fix was this:
mysql -u root -p <<_EOF_ ALTER USER 'debian-sys-maint'@'localhost' IDENTIFIED BY '`sudo grep --only-matching --max-count=1 --perl-regexp 'password\s*=\s*\K.*' /etc/mysql/debian.cnf | sed --expression='s/'\''/\\'\''/g'`'; _EOF_
This extracts the password from
/etc/mysql/debian.cnf making sure to escape any single quotes it might contain:
sudo grep \ --only-matching \ --max-count=1 \ --perl-regexp \ 'password\s*=\s*\K.*' \ /etc/mysql/debian.cnf \ | sed \ --expression='s/'\''/\\'\''/g'`
and inserts it in this bit of SQL:
ALTER USER 'debian-sys-maint'@'localhost' IDENTIFIED BY '<extracted-and-escaped-pw-inserted-here>';
... which is then fed directly to the standard input of the
mysql -u root -p client.
For Debian 9 (Stretch): the
debian-sys-maint user is gone, so the solution is to get rid of the
debian.cnf in either:
/etc/logrotate.d/mysql-server(for MariaDB or MySQL)
/etc/logrotate.d/percona-xtradb-cluster-5.7(for Percona XtraDB Cluster)
In this file you'll find:
which should be changed to:
I had to change it with Percona XtraDB Cluster, which for the time being isn't released for Debian Stretch, hence the logrotate script is currently wrong.