更改了数据库数据目录后更新 MariaDB 无法启动(lower-test)

2021年8月10日

由于更改了数据库数据目录,执行 apt-get  upgrade 升级可能造成无法启动数据库 ,出现如下报错

Can’t create test file xxx lower-test 

这是由于MariaDB启动项默认的目录已经不是/var/lib/mysql

To run MariaDB SQL from /home, in the file /usr/lib/systemd/system/mariadb.service or /lib/systemd/system/mariadb.service, just change :

ProtectHome=true

to :

ProtectHome=false

然后重载配置

systemctl daemon-reload

 

或者

The answer by Thomas is correct, but get's reset by updates every few months. So here is a permanent solution:

Use systemctl edit mariadb to create a file overwritting the default settings of the mariadb service. (In debian it's located in /etc/systemd/system/mariadb.service.d/override.conf)

Set the same setting Thomas changed in the file:

[Service]
ProtectHome=false

Use systemctl daemon-reload to reload the systemctl config.

参照:https://stackoverflow.com/questions/38529205/mariadb-cannot-start-after-update-warning-cant-create-test-file-home-mysql

 

没有评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注