My (SQL) WorkLog: Relocating MySQL DATADIR under Unix -

Thursday, June 11, 2009

Relocating MySQL DATADIR under Unix -

To relocate a database directory under Unix, use the following procedure:

a) Bring down MySQL server if it is running
b) Create the directories that will be new datadir
c) chown the directory to the mysql:mysql user
d) copy the files from the old datadir to the new location. (If you are using InnoDB then make sure that the files named ib_log* etc. are not copied to the newer location).
e) Make sure that the files and directories are owned by mysql user
f) Make changes in the my.cnf to point to the new datadir.
g) Bring up MySQL server You can verify this by creating a new database and verify that the files for this database are getting created in the new datadir

NOTE: The same procedure applies when you are relocating DATADIR under Windows.

1 comment:

Unknown said...

If mysqld don't start:

g) edit /etc/apparmor.d/usr.sbin.mysqld

change location of data dir

/etc/init.d/apparmor restart

/etc/init.d/mysql start

Post a Comment