1. 问题描述
修改 MariaDB 路径到 home 路径下,
执行 systemctl start mariadb 启动MariaDB 时,报错提示:
Job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service" and "journalctl -xe" for details.
2. 问题分析
systemctl status mariadb.service 查看报错详情
[Warning] Can't create test file /home/data/mariadbData/localhost.lower-test
mariadb.service: main process exited, code=exited, status=1/FAILURE
Failed to start MariaDB 10.3.9 database server.
问题的原因是因为 mariadb 没有 home 路径的权限
3. 解决方案
-
关闭 selinux
-
修改 存储路径权限
chown -R mysql:mysql /home/mysqldata chmod -R 764 /home/mysqldata
-
如果你的存储路径是home 下面的路径,那么接下来是重点:
vim /usr/lib/systemd/system/mariadb.service # 编缉文件,并将ProtectHome值修改为false [Service] ProtectHome=false
-
然后执行
systemctl daemon-reload 或者 systemctl --system-daemon-reload
-
最后重启mariadb
systemctl start mariadb
如果启动失败了,可参考附录A中的文档。