| 1 | |
| 2 | == How to move a MySQL database to another partition == |
| 3 | |
| 4 | 1) Create the database in MySQL |
| 5 | |
| 6 | 2) Stop the MySQL database |
| 7 | "/etc/init.d/mysql stop" |
| 8 | |
| 9 | 3) Move the folder to the new directory to the new partition (/your/new/location/. |
| 10 | |
| 11 | 4) Give MySQL ownership of the directory |
| 12 | "chown -R mysql:mysql /your/new/location/MySQLdatabase" |
| 13 | |
| 14 | 5) Create a Symlink between the old directory and the new created dir. |
| 15 | "ln -s /your/new/location/MySQLdatabase /var/lib/mysql/MySQLdatabase" |
| 16 | |
| 17 | 6) Edit the AppArmor file (Most often located at: /etc/apparmor.d/usr.sbin.mysqld) |
| 18 | Add the location of your database to the file. |
| 19 | " /your/new/location/ rw," |
| 20 | " /your/new/location/* rw," |
| 21 | |
| 22 | 7) Restart AppArmor |
| 23 | "service apparmor restart" |
| 24 | |
| 25 | 8) Restart the MySQL database |
| 26 | "/etc/init.d/mysql start" |
| 27 | |
| 28 | |
| 29 | More information on: |
| 30 | http://mysqlhacker.com/kabir/tablespace/distributing-your-mysql-database-across-disk-partitions.html |
| 31 | http://www.ubuntu-howto.info/howto/how-to-move-mysql-databases-to-another-location-partition-or-hard-drive |
| 32 | http://chrisjean.com/2010/05/21/mysql-error-1018-unable-to-follow-symlink-in-ubuntu/ |