圈小蛙

系统update之后MariaDB无法启动,提示[Warning] Can’t create test file /home/data/mysql/localhost.lower-test

使用yum update更新MariaDB后,启动MariaDB出错,提示:

Oct 06 17:39:48 localhost.localdomain systemd[1]: Starting MariaDB 10.8.5 database server…
Oct 06 17:39:48 localhost.localdomain mariadbd[22402]: 2022-10-06 17:39:48 0 [Note] /usr/sbin/mariadbd (server 10.8.5-MariaDB-log) starting as process 22402 …
Oct 06 17:39:48 localhost.localdomain mariadbd[22402]: 2022-10-06 17:39:48 0 [Warning] Can't create test file /home/data/mysql/localhost.lower-test
Oct 06 17:39:48 localhost.localdomain mariadbd[22402]: [98B blob data]
Oct 06 17:39:48 localhost.localdomain mariadbd[22402]: 2022-10-06 17:39:48 0 [ERROR] Aborting
Oct 06 17:39:48 localhost.localdomain systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE
Oct 06 17:39:48 localhost.localdomain systemd[1]: Failed to start MariaDB 10.8.5 database server.
Oct 06 17:39:48 localhost.localdomain systemd[1]: Unit mariadb.service entered failed state.
Oct 06 17:39:48 localhost.localdomain systemd[1]: mariadb.service failed.

以为是文件夹权限问题,把mysql文件夹设置为mysql用户与组,且给了777读写权限:

chmod -R 777 /home/data/mysql/
chown -R mysql.mysql /home/data/mysql/

依旧报同样错误。于是搜了下,遇到此问题的朋友比较多,也直接给出了解决方法。

高版本的MariaDB、mysql默认拒绝了对/home、/root、/run/user的访问,需要在/usr/lib/systemd/system/mariadb.service/lib/systemd/system/mariadb.service文件中,将
ProtectHome=true
修改为
ProtectHome=false

然后

systemctl daemon-reload
systemctl start mariadb

正常,解决问题。

Exit mobile version