Error: 'logrotate exited with return code 1' on Ubuntu

For the past several days I've been seen the following error on one of our Ubuntu boxes:

/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

A quick google search found several possible solutions, and this one correct solution to the issue we were having. On Ubuntu, there is a system MySQL user called 'debian-sys-maint' that is required by some init scripts to control MySQL. This users password is stored in plain text in the file '/etc/mysql/debian.cnf'. The fix is to retrieve the password from this file and update that correct user in MySQL:


cat /etc/mysql/debian.cnf
# Automatically generated for Debian scripts. DO NOT TOUCH!
# This was updated via a 1-Click HotFix on Mon, 18 Sep 2017 14:23:09 -0400
[client]
host     = localhost
user     = debian-sys-maint
password = secret-password-here
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = debian-sys-maint
password = secret-password-here
socket   = /var/run/mysqld/mysqld.sock

Now that you the Ultra secret password, lets upgrade the MySQL user:


mysql
mysql> SET PASSWORD FOR `debian-sys-maint`@`localhost` = PASSWORD('secret-password-here');
mysql> flush privileges;
mysql> exit;

You should now be done! Special thanks to the owner this blog. They've got some great info there, check it out!

Comments