How to move MySQL database to another drive
Step 1:
Login to your MySQL server, enter your password when prompted:
|
|
Find out where the data directory
is located:
|
|
Step 2:
Now you can stop the server and check the status:
|
|
|
|
It’s time to make a copy to your new mount location:
|
|
Remember to create a backup of the original data in case you need to revert at a later stage:
|
|
Step 3:
Edit the MySQL configuration to update the datadir
to the new location:
|
|
Find the datadir
key and swap the value with your new mount path:
Step 4:
Update AppArmor to point to a new location:
|
|
Create a new line at the bottom that references your new mount path, aliased back to /var/lib/mysql
.
Restart AppArmor to pull in the new configuration.
|
|
Step 5:
Start the MySQL server for changes to take effect.
Login to MySQL again to verify it is using the new directory:
|
|
Re-run the command from before to verify:
|
|