mysqladmin 產生「錯誤」訊息

mysqladmin 產生「錯誤」訊息

不久前,我在執行 Raspbian 的 Raspberry Pi 上安裝了 NGINX、php7、mariaDB 和 Wordpress。

我創建了一個 Wordpress 資料庫 - 它正在運行。

最近我在我的系統上安裝ssmtpmailutils發送郵件。

現在我每天都會收到一封電子郵件,其中包含以下錯誤

/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

這有點煩人。沒有文件/var/log/mysql/mysql.log

mysql的root用戶確實有密碼。

我可以做什麼來抑制錯誤訊息?

編輯


/etc/cron.daily/logrotate來電/etc/logrotate.conf

其中包含

# rotate log files weekly
weekly
# packages drop log rotation information into this directory
include /etc/logrotate.d

包括

/etc/logrotate.d/mysql-server

# - I put everything in one block and added sharedscripts, so that mysql gets
#   flush-logs'd only once.
#   Else the binary logs would automatically increase by n times every day.
# - The error log is obsolete, messages go to syslog now.
/var/log/mysql/mysql.log /var/log/mysql/mysql-slow.log /var/log/mysql/mariadb-slow.log /var/log/mysql/error.log {
    daily
    rotate 7
    missingok
    create 640 mysql adm
    compress
    sharedscripts
    postrotate
          test -x /usr/bin/mysqladmin || exit 0
          if [ -f `my_print_defaults --mysqld | grep -m 1 -oP "pid-file=\K.+$"` ]; then
            # If this fails, check debian.conf!
            mysqladmin --defaults-file=/etc/mysql/debian.cnf --local flush-error-log \
              flush-engine-log flush-general-log flush-slow-log
          fi
    endscript
}

/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

答案1

  • 前往您的 mysql/mariadb 用戶端並確保debian 系統維護密碼為空的使用者已存在於使用者表的mysql資料庫

  • 預設/etc/mysql/debian.cnf應包含debian 系統維護作為使用者代替

# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = debian-sys-maint
password =
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = debian-sys-maint
password =
socket   = /var/run/mysqld/mysqld.sock
basedir  = /usr

相關內容