1、把mariadb服务停掉:
service mariadb stop
2、把/var/lib/mysql整个目录复制到/work,
sudo mkdir /work/data
sudo cp -arp /var/lib/mysql/ /work/data
sudo mv /var/lib/mysql /var/lib/mysql.bak
这样就把MySQL的数据文档复制到了/work/data下了
4、编辑mariadb的配置文档
sudo vi /etc/my.cnf.d/client.cnf
[client]
socket=/work/data/mysql/mysql.sock
#:wq 保存退出
sudo vi /etc/my.cnf.d/server.cnf
[mysqld]
character-set-server = utf8
collation-server = utf8_general_ci
socket=/work/data/mysql/mysql.sock
datadir=/work/data/mysql
#:wq 保存退出
5、重新启动mariadb服务
sudo service mariadb start