修改 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.
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 路徑的權限
解決方法:
1. 關閉 selinux
2. 修改 存儲路徑權限,
chown -R mysql:mysql /home/mysql_data chmod -R 764 /home/mysql_data
3. 如果你的存儲路徑是home 下面的路徑,那么接下來是重點:
vim /etc/systemd/system/mariadb.service.d/homedir.conf
輸入以下內容
[Service] ProtectHome=false
然后執行
systemctl daemon-reload
重啟mariadb
systemctl start mariadb