Move MySQL to Home Partition

From Tech Wiki
Jump to navigation Jump to search

To move MySQL from /var/lib/mysql to /home/mysql please do the following:

Use the following command to stop MySQL:

service mysqld stop

Use the following command to edit the MySQL Config File:

vi /etc/my.cnf

Then change the following:

datadir=/var/lib/mysql

To the following:

datadir=/home/mysql

Then use the following command to make the /home/mysql directory:

mkdir /home/mysql

Then set the ownership of this directory using the following command:

chown mysql:mysql /home/mysql

Then move the MySQL files using the following command:

mv /var/lib/mysql/* /home/mysql/

Use the following command to restart MySQL:

service mysqld restart

Then perform a mysqlcheck using the following command:

mysqlcheck –Ar

Wait for this to finish and it should be fine.

If this is done on a backup server perform the following commands:

service bacula-sd restart
service bacula-fd restart
service bacula-dir restart