Plesk

Messages about failed logrotate task are received in Plesk on Ubuntu 18 or Debian 9: ‘Access denied for user ‘root’@’localhost’ (using password: NO)

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:

Resolution

Install Plesk updates

In case Plesk updates can not be installed, following workaround can be applied in Debian based operating systems:

Create a MySQL root user

  1. Connect to the server via SSH

  2. Create a backup of the initial configuration file:

    # cp -a /etc/mysql/debian.cnf /root/debian.cnf

  3. Create MySQL database backup:

    # MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysqldump -u admin mysql > "mysql`date +%F_%H.%M`.sql"

  4. Access MySQL:

    # plesk db

  5. Create MySQL user root with password:

    GRANT RELOAD, SHUTDOWN, PROCESS, SHOW DATABASES, SUPER, LOCK TABLES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'your_password';

  6. Exit MySQL:

    exit;

  7. 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

  8. 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

Exit mobile version