The default data document storage directory of mariadb is/var/lib/mysql. to change the default directory to/data, perform the following operations: 1. create the/data Directory mkdir/datachmod777/data (to assign at least the read and write permissions to this directory). 2. stop the mariadb service: the default data document storage directory of mariadb is/var/lib/mysql. to change the default directory to/data, perform the following operations:
1. create/data Directory
Mkdir/data
Chmod 777/data (at least read and write permissions must be attached to this directory)
2. stop the mariadb service:
Systemctl stop mariadb. service
3. copy the entire/var/lib/mysql directory to/data
Cp-r/var/lib/mysql/*/data/
In this way, the MySQL data file is copied to/data.
4. edit the configuration document/etc/my. cnf of mariadb.
Add the following under [client:
Comment out the original socket =/var/lib/mysql. sock, add # to the front, and add socket =/data/mysql. sock (in case of any problem, change it back ).
Add the following under [mysqld:
Comment out the original socket =/var/lib/mysql. sock, add # to the front, and add socket =/data/mysql. sock (in case of any problem, change it back ).
Datadir =/datal (this line does not exist. you need to add it yourself)
Save and exit.
5. chown-R mysql: mysql/data/mysql
6. restart the mariadb service.
Systemctl start mariadb. service.