Modify the default storage path of mariadb

First, the mariadb service starts normally
and install mariadb:

https://blog.csdn.net/qq_50247813/article/details/135402502?spm=1001.2014.3001.5502

Stop mariadb service

systemctl  stop  mariadb

Create a new data storage directory

mkdir /data

Copy mariadb data to the /data directory

mv /var/lib/mysql /data

Modify configuration configuration

vi /etc/my.cnf.d/server.cnf
[mysqld]
datadir=/data/mysql
socket=/data/mysql/mysql.sock

[client]
socket=/data/mysql/mysql.sock

Restart mariadb

systemctl restart mariadb

View the current data storage directory
and log in to the database

Mariadb 
MariaDB [(none)]> SHOW VARIABLES LIKE 'datadir';

Insert image description here

Guess you like

Origin blog.csdn.net/qq_50247813/article/details/135407625