27 05 2021

Debian10.3 (Debian9+) MariaDB修改datadir 权限错误无法启动


apt-get -y install mariadb-server

#安装命令

确保安装成功.

service mariadb status

无报错日记.


停止 MariaDB 运行

service mariadb stop


开始修改 MariaDB 的 datadir 位置:

sed -e "s/var/lib/mysql$/home/mysql-date/" -e "s/^bind-address/#bind-address/" /etc/mysql/mariadb.conf.d/50-server.cnf -i

sed -e "s/^ProtectHome=true/ProtectHome=false/" /etc/systemd/system/mysql.service -i

sed -e "s/^ProtectHome=true/ProtectHome=false/" /etc/systemd/system/mysqld.service -i


移动数据库相关文件和运行home目录作为储存

mv -u /var/lib/mysql/* /home/mysql-date

chown mysql:mysql /home/mysql-date

mkdir -p /etc/systemd/system/mariadb.service.d/


cat <<EOF >/etc/systemd/system/mariadb.service.d/override.conf

[Service]

ProtectHome=false

EOF

systemctl daemon-reload

service mariadb start


MariaDB完成转移并正常启动


程序版本:Server version: 10.3.27-MariaDB-0+deb10u1 Debian 10

默认位置:/var/lib/mysql

目标位置:/home/mysql-date


应用程序防护:SELINUX 未安装 && apparmor 未启用

setenforce 0

#-bash: setenforce:未找到命令

grep -r maria /etc/apparmor

grep -r mysql /etc/apparmor

#返回为空


报错示意:

Active: failed


[Warning] Can't create test file

[ERROR] Aborting

#Can't Create Test File

#This is usually a permission error on the directory in which this file is being written. Ensure that the entire datadir is owned by the user running mysqld, usually mysql. Ensure that directories have the "x" (execute) directory permissions for the owner. Ensure that all the parent directories of the datadir upwards have "x" (execute) permissions for all (user, group, and other).


[99B blob data]

#"Fatal error in defaults handling" looks like one of your config files isn't readable by the mysqld process (which would be running as the mysql user).


  1. 上一篇:利用宝塔搭配nginx开启webdav
  2. 下一篇:centos7设置CPU的运行频率为performance
发表评论