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


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 '11 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 '11 at 1:26
  • what is this I don't even.. – phoops May 17 '14 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 '16 at 13:17

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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.