Wednesday, January 13, 2010

MySQL: Changing data directory on Ubuntu 9.04

You would think it is a pretty easy task to go to the /etc/mysql/my.cnf file and change the datadir to the new directory, then restart MySQL. However, MySQL will fail every time you restart it. There are a couple of considerations to make when you do this change:

1- Make a copy of all databases to the new directory.
2- Change the datadir configuration on /etc/mysql.my.cnf
3- Change /etc/apparmor.d/usr.sbin.mysqld so the old data dir is no longer there.
4- Reload Apparmor daemon.
5- Verify ownership and pem on new data dir.
6- Restart MySQL

You can follow this blog http://blog.taragana.com/index.php/archive/how-to-move-the-mysql-data-directory-in-ubuntu/ for more detailed instructions.

Enjoy it...

1 comment: