mysql
默认存储路径在/etc/mysql/mysql.conf.d/mysqld.cnf
中的datadir
配置项。
datadir = /var/lib/mysql
mysql
服务sudo systemctl stop mysql
sudo mv /var/lib/mysql /mnt/data
修改/etc/mysql/mysql.conf.d/mysqld.cnf
配置文件,把datadir
修改为新数据目录:
datadir = /mnt/data/mysql
sudo vim /etc/apparmor.d/usr.sbin.mysqld
把:
# Allow plugin access
/var/lib/mysql/plugin/ r,
/var/lib/mysql/plugin/*.so* mr,
修改为:
# Allow plugin access
/mnt/data/mysql/plugin/ r,
/mnt/data/mysql/plugin/*.so* mr,
AppArmor
访问控制规则sudo vim /etc/apparmor.d/tunables/alias
在最后添加别名
# Or if mysql databases are stored in /home:
# alias /var/lib/mysql/ -> /home/mysql/,
alias /var/lib/mysql/ -> /mnt/data/mysql,
apparmor
服务systemctl restart apparmor
mysql
sudo systemctl start mysql