Step 1 — Transferring the MariaDB Information Listing
mysql -u root -p
choose @@datadir;
Output:
+-----------------+
| @@datadir |
+-----------------+
| /var/lib/mysql/ |
+-----------------+
1 row in set (0.00 sec)
exit
sudo systemctl cease mariadb
sudo systemctl standing mariadb
Output:
mysql systemd[1]: Stopped MariaDB database server.
sudo rsync -av /var/lib/mysql /mnt/my-volume-01
sudo mv /var/lib/mysql /var/lib/mysql.bak
Step 2 — Pointing to the New Information Location
sudo vi /and so on/my.cnf
[mysqld]
. . .
datadir=/mnt/my-volume-01/mysql
socket=/mnt/my-volume-01/mysql/mysql.sock
. . .
[client]
port=3306
socket=/mnt/my-volume-01/mysql/mysql.sock
!includedir /and so on/my.cnf.d
Step 3 — Restarting MariaDB
sudo systemctl begin mariadb
sudo systemctl standing mariadb
mysql -u root -p
choose @@datadir;
Output
+----------------------------+
| @@datadir |
+----------------------------+
| /mnt/my-volume-01/mysql/ |
+----------------------------+
1 row in set (0.01 sec)
exit
Cleanup
sudo rm -Rf /var/lib/mysql.bak