Symptoms
Plesk administrator receives messages about failed logrotate tasks:
/etc/cron.daily/logrotate:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
error: error running shared postrotate script for '/var/log/mysql/mysql.log /var/log/mysql/mysql-slow.log /var/log/mysql/mariadb-slow.log /var/log/mysql/error.log '
run-parts: /etc/cron.daily/logrotate exited with return code 1
Cause
Plesk bug with ID #PPPM-8915 fixed in:
- Plesk Onyx 17.8 25 March 2019
- Plesk Obsidian 28 August 2018 (fixed as PPP-37427, Linux)
Resolution
In case Plesk updates can not be installed, following workaround can be applied in Debian based operating systems:
Create a MySQL root user
-
Connect to the server via SSH
-
Create a backup of the initial configuration file:
# cp -a /etc/mysql/debian.cnf /root/debian.cnf
-
Create MySQL database backup:
# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysqldump -u admin mysql > "mysql`date +%F_%H.%M`.sql"
-
# plesk db
-
Create MySQL user
root
with password:GRANT RELOAD, SHUTDOWN, PROCESS, SHOW DATABASES, SUPER, LOCK TABLES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'your_password';
-
Exit MySQL:
exit;
-
Modify
/etc/mysql/debian.cnf
and specify user with password created above:[client]
host = localhost
user = root
password = "your_password"
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = root
password = "your_password"
socket = /var/run/mysqld/mysqld.sock
basedir = /usr -
Make sure that logrotate works. If the command doesn't show the output then everything works properly:
# mysqladmin --defaults-file=/etc/mysql/debian.cnf --local flush-error-log