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

3 Answers 3


The shared postrotate script tries to access the mysql database but fails to do so, probably because the password doesn't match.

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.

cat /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.


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:

/etc/init.d/mysql restart

However, the restart is not required.

  • 2
    Thanks me, this information is available on the internet, but the most popular post says to put the phrase IDENTIFIED BY PASSWORD in the mysql command instead of just IDENTIFIED BY.
    – Chris H.
    Oct 27, 2011 at 1:21
  • 2
    Your welcome other me. The crazy thing is that when you do use IDENTIFIED BY PASSWORD 'testpass', mysql will actually set the user's password to 'testpass' in plain text! Making the actual password readable to anyone who has read access to the 'mysql' table. This is clearly not good. So thank you for posting this question, it needed to be cleared up.
    – Chris H.
    Oct 27, 2011 at 1:26
  • what is this I don't even..
    – ek9
    May 17, 2014 at 20:09
  • I have Ubuntu 15.10 and the /etc/mysql/debian.cnf file shows user root and password is empty. I mean there's no debian-sys-maint user. What would be the solution here?
    – aesede
    Apr 19, 2016 at 13:17
  • For me , the password field was blank in debian.cnf (Debian 10 , MariaDB 10.6.4)
    – Kiran RS
    Aug 11, 2021 at 15:46

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'`';

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                                 \

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:

            MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"

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.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .