Issue
You get the following errors from your server after running schedule 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
You get this error when running the command in ssh
mysqladmin --defaults-file=/etc/mysql/debian.cnf --local flush-error-log
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
Cause
User root
with no password is stored in the file /etc/mysql/debian.cnf
:
[client]
host = localhost
user = root
password =
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = root
password =
socket = /var/run/mysqld/mysqld.sock
basedir = /usr
Solution
- ssh to your server and run the following commands
plesk db
CREATE USER 'root'@'localhost' IDENTIFIED BY 'PASSWORD HERE';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost';
GRANT RELOAD, SHUTDOWN, PROCESS, SHOW DATABASES, SUPER, LOCK TABLES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'PASSWORD HERE';
FLUSH PRIVILEGES;
exit
- Make sure you can login with the account
mysql -u root -p
- Edit config file
nano /etc/mysql/debian.cnf
- Enter the password from 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
- Test again
mysqladmin --defaults-file=/etc/mysql/debian.cnf --local flush-error-log