Logrotate Error on Ubuntu
/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 :)
Works Fine for me !
Thanks a lot for this information.
(My user wasn’t lost. Only its password)
Bousteur: I’m glad this was helpful, thanks for adding the comment about the lost password.
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)!
Glad it helped – thanks for updating with your platform information :)
Thanks for the tip, it works for me, altough you have to remove the word ‘PASSWORD’ from the mysql sentence to make it work.
Thanks!
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.
Thanks for the helpful posts!
I also ran into this after moving a database from an older Debian server to a newer Ubuntu one. Since I moved *all* databases, including users, this set the password for debian-sys-maint to the one randomly generated on the old system. I fixed this by copying /etc/mysql/debian.cnf from the old system to the new system, so the passwords once again match.
I had the same issue in 10.04 server. Thanks LornaJane!
Thanks for the tip, it works for me. I was moving from Ubuntu 8.04 to Ubuntu 10.04. Furthermore, I think Carl Nobile is right.
Thanks for the post. Helped me out. Debian Squeeze.
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.
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';
Works Fine for me !
Thanks a lot for this information.
Thanks for the tip!
I think my debian-sys-maint password was lost because I did a full replication, that included the users database.
I had the same problem as Kim when I replaced an old dev server with a new one.
This has saved me from the anoying daily emails.
Thank you for blogging about this.
Because of the MySQL passwords in my Ubuntu box (12.04 LTS) were hashed, I have to remove the PASSWORD keyword on the SQL statement like the following to make it work:
GRANT RELOAD, SHUTDOWN, PROCESS, SHOW DATABASES, SUPER, LOCK TABLES ON *.* TO ‘debian-sys-maint’@’localhost’ IDENTIFIED BY ‘xxxxxxxxxxxx’;
Thanks!
+1
Thanks a bunch !
This worked on the Debian Squeeze x64 server I just deployed, thanks for posting this!
Thanks for this tip!
Thank you! This tip is working on ubuntu 12.04.
Thanks, this fixed the problem for me. I found that you can also test if the maintenance user has its permissions set correctly with the following so you don’t have to wait for cron to run it to see if the problem’s fixed.
mysqladmin –defaults-file=/etc/mysql/debian.cnf ping
Thank you so much for this!
Just as a reminder you may have to run FLUSH PRIVILEGES; after the above commands.
an all in one bash one liner would be:
[code]
echo “GRANT RELOAD, SHUTDOWN, PROCESS, SHOW DATABASES, SUPER, LOCK TABLES ON *.* TO ‘debian-sys-maint’@’localhost’ IDENTIFIED BY ‘$(grep -m 1 password /etc/mysql/debian.cnf | cut -d” ” -f3)’; flush privileges;” | mysql -u root
[/code]
Nice! Good support :). I’m here every now and then to update..