Cron (logrotate) error rotating MySQL logs

Setup a new backup server and getting the following error from Cron in /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

The problem was that I imported all DBs from the prod server, which had a different password for the debian-sys-maint user so the following test would fail:

# mysqladmin --defaults-file=/etc/mysql/debian.cnf ping
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'debian-sys-maint'@'localhost' (using
password: YES)'

Easy fix is to copy the password from /etc/mysql/debian.cnf from the prod to the backup. Now this works:

# mysqladmin --defaults-file=/etc/mysql/debian.cnf ping
mysqld is alive

... and MySQL logs are getting rotated again.

Leave a comment

NOTE: Enclose quotes in <blockquote></blockquote>. Enclose code in <pre lang="LANG"></pre> (where LANG is one of these).