wiki:MoveDatabaseToOtherPartition

How to move a MySQL database to another partition

1) Create the database in MySQL

2) Stop the MySQL database

/etc/init.d/mysql stop

3) Move the folder to the new directory to the new partition (/your/new/location/)

4) Give MySQL ownership of the directory

chown -R mysql:mysql /your/new/location/*

5) Create a Symlink between the old directory and the new created dir.

ln -s /your/new/location/MySQLdatabase /var/lib/mysql/MySQLdatabase

6) Edit the AppArmor? file (Most often located at: /etc/apparmor.d/usr.sbin.mysqld)

Add the location of your database to the file.

   /your/new/location/ r,
   /your/new/location/** rwk,

7) Restart AppArmor?

service apparmor restart

8) Restart the MySQL database

/etc/init.d/mysql start

More information on: http://mysqlhacker.com/kabir/tablespace/distributing-your-mysql-database-across-disk-partitions.html http://www.ubuntu-howto.info/howto/how-to-move-mysql-databases-to-another-location-partition-or-hard-drive http://chrisjean.com/2010/05/21/mysql-error-1018-unable-to-follow-symlink-in-ubuntu/

Last modified 13 years ago Last modified on 2011-04-13T09:27:13+02:00