Methods to Exchange a MariaDB/MySQL Knowledge Listing to a New Location on Linux

Step 1 — Transferring the MariaDB Knowledge Listing

mysql -u root -p
make a selection @@datadir;
Output:
  +-----------------+
  | @@datadir       |
  +-----------------+
  | /var/lib/mysql/ |
  +-----------------+
  1 row in set (0.00 sec)
go out
sudo systemctl forestall 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 Knowledge Location

sudo vi /and so forth/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 forth/my.cnf.d

Step 3 — Restarting MariaDB

sudo systemctl get started mariadb
sudo systemctl standing mariadb
mysql -u root -p
make a selection @@datadir;
Output
+----------------------------+
| @@datadir                  |
+----------------------------+
| /mnt/my-volume-01/mysql/ |
+----------------------------+
1 row in set (0.01 sec)
go out

Cleanup

sudo rm -Rf /var/lib/mysql.bak

Like this post? Please share to your friends:
Leave a Reply

;-) :| :x :twisted: :smile: :shock: :sad: :roll: :razz: :oops: :o :mrgreen: :lol: :idea: :grin: :evil: :cry: :cool: :arrow: :???: :?: :!: