如果尝试启动MariaDB时出现启动错误(错误代码: 13 “权限被拒绝”),可采取以下解决方法

修改了my.cnf的Mariadb保存目录之后,尝试启动Mariadb时出现了以下错误,无法启动。

Jan 10 10:03:42 localhost mysqld: 2018-01-10 10:03:42 140713415448832 [Warning] Can't create test file /home/mysql/localhost.lower-test
Jan 10 10:03:42 localhost mysqld: #007/usr/sbin/mysqld: Can't change dir to '/home/mysql/' (Errcode: 13 "Permission denied")
Jan 10 10:03:42 localhost mysqld: 2018-01-10 10:03:42 140713415448832 [ERROR] Aborting
Jan 10 10:03:42 localhost systemd: mariadb.service: main process exited, code=exited, status=1/FAILURE

由于默认启用了保护功能,将修改/usr/lib/systemd/system/mariadb.service文件如下:

# Prevent writes to /usr, /boot, and /etc
ProtectSystem=off

# Doesn't yet work properly with SELinux enabled
# NoNewPrivileges=true

PrivateDevices=true

# Prevent accessing /home, /root and /run/user
ProtectHome=false

如果成功启动Mariadb并正常运行,则OK。

广告
将在 10 秒后关闭
bannerAds