Written by Zack MIlls
|
Friday, 11 September 2009 09:51 |
Process- Open the terminal
- Stop MySQL with the command
sudo /etc/init.d/mysql stop - Copy the existing data directory (which is located in /var/lib/mysql) using the command
sudo cp -R -p /var/lib/mysql /path/to/new/datadir - All you need are the data files. Delete the others with the command
sudo rm /path/to/new/datadir (You will get a message about not being able to delete some directories, but do not care about them) - Edit the MySQL configuration file with the command
gksu gedit /etc/mysql/my.cnf - Find the entry for datadir, change the path to the new data directory.
- But there is a trick involved here. Ubuntu uses some security software called AppArmor that specifies the areas of your filesystem applications are allowed to access. Unless you modify the AppArmor profile for MySQL, you'll never be able to restart MySQL with the new datadir location.
- Restart MySQL with the command
sudo /etc/init.d/mysql restart - MySQL should now start without any errors and your data will be stored in the new location. If an error finds you do check the process carefully again.
Good Luck!
|