/etc/cron.daily/logrotate:error: error running shared postrotate script for ‘/var/log/mysql.log

/etc/cron.daily/logrotate:
/usr/bin/mysqladmin: refresh failed; error: ‘Access denied; you need the RELOAD
privilege for this operation’
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 = ******
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = ******
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 🙂

aiticle from:http://www.lornajane.net/posts/2008/Logrotate-Error-on-Ubuntu

Comments are closed.