Logrotate Error on Ubuntu

For a few weeks now, I've been seeing this error in my logs every night:

/etc/cron.daily/logrotate:
error: error running shared postrotate script for /var/log/mysql.log /var/log/mysql/mysql.log /var/log/mysql/mysql-slow.log
run-parts: /etc/cron.daily/logrotate exited with return code 1

What's happening is that after all the mysql backing up and everything is done, ubuntu is trying to use the debian-sys-maint user to flush the logs, this is actually called in /etc/logrotate.d/mysql-server. On my system, we seem to have lost this mysql user.

The solution is to look for the password used in the /etc/mysql/debian.cnf file, mine looks like this:

# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = debian-sys-maint
password = xxxxxxxxxxxxxxxx
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
user     = debian-sys-maint
password = xxxxxxxxxxxxxxxx
socket   = /var/run/mysqld/mysqld.sock
basedir  = /usr

Using the password, and some inspiration from this post on the Ubuntu Forums I recreated the user with the necessary permissions and password with:

GRANT RELOAD, SHUTDOWN, PROCESS, SHOW DATABASES, SUPER, LOCK TABLES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY PASSWORD 'xxxxxxxxxxxxxxxx'

This did the trick, as the nightly errors have now disappeared from my script. Hope this helps someone in a similar situation - if you can expand these notes then please add a comment and I will update this as needed - thanks :)

13 thoughts on “Logrotate Error on Ubuntu

  1. I did not immediately see that the "PASSWORD" in the mysql query was the one found on the /etc/mysql/debian.cnf file.
    Thanks a lot for this trick! It also works fine for me (Debian 2.4.26 with mysql server version: 5.0.32-Debian_7etch5-log)!

  2. This issue seems to happen when you move a DB from one machine to another as I did. The procedure you describe above should be put into MySQL documentation. You should put in a bug report to the MySQL people as their documentation needs to updated. And yes the PASSWORD parameter needs to be removed or the password will not get encrypted.

    • Carl, I also moved a DB from one machine to another and had this problem. Thanks for calling it out.
      LomaJane, thanks for the info.

  3. In case it does not work, try:

    update user set password=PASSWORD("xxxxxxxxxxxxxxx") where User='debian-sys-maint';

    In my cases the passwords were hashed.

  4. Awesome, thanks for that. This error has been bugging me for a few weeks now. I finally got around to searching for it and bingo, problem solved. In my case the user's password had changed, so I changed it back, and bob's yer uncle.
    UPDATE user SET Password = PASSWORD('passwordFromFile') WHERE User = 'debian-sys-maint' && Host = 'localhost';

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">