Monday, October 16, 2023
HomeSoftware EngineeringThe way to Change a MariaDB/MySQL Information Listing to a New Location...

The way to Change a MariaDB/MySQL Information Listing to a New Location on Linux


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



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments