![重置mysql root密码后logrotate出现问题](https://linux22.com/image/743095/%E9%87%8D%E7%BD%AEmysql%20root%E5%AF%86%E7%A0%81%E5%90%8Elogrotate%E5%87%BA%E7%8E%B0%E9%97%AE%E9%A2%98.png)
不久前,我不得不重置我忘记的 mysql(严格来说是 mariadb)的 root 密码,并找到了一个合适的操作方法(可能是这个 https://devanswers.co/how-to-reset-mysql-root-password-ubuntu/) 并使用了强密码。虽然之后一切似乎都运行正常,但有一个问题不断出现:logrotate 的每日 cron 作业失败:
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
由于 logrotate 配置包含有用的行
# If this fails, check debian.conf!
[原文如此],我看了一下/etc/mysql/debian.cnf
:
# Automatically generated for Debian scripts. DO NOT TOUCH!
[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
显然,新创建的密码应该添加到此文件中(两次,否则下次软件更新时我会遇到问题),但事实并非如此。虽然我现在可能就这么做了,但这会与第一行相冲突,DO NOT TOUCH!
我猜想这个文件会在某个时候被系统重写?如果是这样,那么存储我“手动”创建的新密码的正确其他地方是什么?