https://blog.csdn.net/kylinregister/article/details/81252781
https://blog.csdn.net/harleylau/article/details/81222949
https://blog.csdn.net/qq_35440678/article/details/78573096
https://blog.csdn.net/n88Lpo/article/details/80090008
https://blog.make3.cn/article/66
vim /etc/apparmor.d/usr.sbin.mysqld
实施步骤
一,查看当前配置信息
mysqld --verbose --help
/etc/mysql/mysql.conf.d/mysqld.cnf
/etc/apparmor.d/usr.sbin.mysqld
二,停止服务器,创建新的datadir并复制数据设定权限
假设新路径为 /path/to/new/datadir
service mysql stop
cp -R -p /var/lib/mysql /path/to/new/datadir
vim /etc/mysql/mysql.conf.d/mysqld.cnf #仅需要设定datadir = /path/to/new/datadir,其他的不要动
vim /etc/apparmor.d/usr.sbin.mysqld #仅需要设定# Allow data dir access下面的2行(即原datadir)添加下面2行
/path/to/new/datadir/ r,
/path/to/new/datadir/** rwk,
chown -R mysql:mysql /path/to/new/datadir
chmod -R 755 /path/to/new/datadir
三,重启服务
service apparmor restart
service mysql restart
坑点:
1,pid-file和socket 不能随便改,否则会出现
-Could not create unix socket lock file
-Unable to setup unix socket lock file