我遇到有關 MariaDB (MySQL) 日誌檔案權限的問題。我已設定日誌文件/var/log/mysql
,但每次重新啟動 MariaDB 伺服器時,我都可以看到以下已登入訊息/var/log/mysql/mysql_error.log
:
151104 20:54:53 [ERROR] mysqld: File '/var/log/mysql/mysql_slow.log' not found (Errcode: 13)
151104 20:54:53 [ERROR] Could not use /var/log/mysql/mysql_slow.log for logging (error 13). Turning logging off for the whole duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server and restart it.
151104 20:54:53 [ERROR] mysqld: File '/var/log/mysql/mysql_query.log' not found (Errcode: 13)
151104 20:54:53 [ERROR] Could not use /var/log/mysql/mysql_query.log for logging (error 13). Turning logging off for the whole duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server and restart it.
/var/log/mysql
我嘗試過在遞歸(-R)上設定權限as mysql:root
,mysql:mysql
但root:root
它們都不起作用,而且我一直收到相同的訊息。我確實檢查了當前的權限/var/log/mysql
並讀取為:
# ls -l mysql/
total 40
-rw-r--r-- 1 mysql root 33088 Nov 4 21:04 mysql_error.log
-rw-r--r-- 1 mysql root 0 Aug 2 16:58 mysql_query.log
-rw-r--r-- 1 mysql root 0 Aug 2 16:58 mysql_slow.log
我在用mysql Ver 15.1 Distrib 5.5.46-MariaDB,適用於 Linux (x86_64),使用 readline 5.1
這裡有什麼問題嗎?在這種情況下哪些是正確的權限?
更新
/var/log
以下是和的權限/var/log/mysql
:
# ls -lhd /var/log/
drwx------ 12 root root 4.0K Nov 4 20:52 /var/log/
# ls -lhd /var/log/mysql
drwxr-xr-x 2 mysql root 4.0K Nov 4 20:52 /var/log/mysql
答案1
我相信你必須授予 mysql 用戶讀取和執行權限/var/log
才能存取/var/log/mysql
.我剛剛在 RHEL7.1 上進行了測試並確認了相同的問題。
這正是@prem 在評論中所建議的。