我遇到有关 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 在评论中建议的。