Moving Mysql database to a different partition in Ubuntu
Haven't had to do something like this before, but at the moment the partition where /var/lib/mysql resides is getting full and I needed to import a large data dump which I know would not fit on the partition. You can easily move the entire mysql data store, but I opted to only move 1 database and here's how to do it.
Stop the mysql service
sudo service mysql stop
cd /var/lib/mysql
db directory is wp-db
mv wp-db /mnt/new-mysql-partition
make sure the permissions are the same and that the ownership of the folder is still mysql.myql
This next part probably applies only to Ubuntu but if you get errors like these, ERROR 1018 (HY000): Can't read dir of foo, then you probably need to do this step as well.
vi /etc/apparmor.d/usr.sbin.mysqld
at the end add something like
/mnt/new-mysql-partition/ r,
/mnt/new-mysql-partition/** rwk,
Stop the mysql service
sudo service mysql stop
cd /var/lib/mysql
db directory is wp-db
mv wp-db /mnt/new-mysql-partition
make sure the permissions are the same and that the ownership of the folder is still mysql.myql
This next part probably applies only to Ubuntu but if you get errors like these, ERROR 1018 (HY000): Can't read dir of foo, then you probably need to do this step as well.
vi /etc/apparmor.d/usr.sbin.mysqld
at the end add something like
/mnt/new-mysql-partition/ r,
/mnt/new-mysql-partition/** rwk,
Comments
Post a Comment