首先mariadb服务正常启动
安装mariadb:
https://blog.csdn.net/qq_50247813/article/details/135402502?spm=1001.2014.3001.5502
停止mariadb服务
systemctl stop mariadb
创建新的数据存放目录
mkdir /data
将mariadb的数据拷贝到/data目录下
mv /var/lib/mysql /data
修改配置配置
vi /etc/my.cnf.d/server.cnf
[mysqld]
datadir=/data/mysql
socket=/data/mysql/mysql.sock[client]
socket=/data/mysql/mysql.sock
重启mariadb
systemctl restart mariadb
查看当前数据的存放目录
登录数据库
Mariadb
MariaDB [(none)]> SHOW VARIABLES LIKE 'datadir';