From Campworld

Linux: HOWTO Move MySQL Databases To A New Location

Status

Introduction

This quick HOWTO covers moving Mysql's database storage to a different location.

Moving Mysql's Databases

First we need to stop mysql if it is running. Type the following:
> service mysqld stop

Next copy the data to the new location and fix the ownership.
> cp -R /var/lib/mysql /home/
> mv /home/mysql /home/databases
> chown -R mysql:mysql /home/databases

Save the old databases directory.
> mv /var/lib/mysql/ /var/lib/mysql_old

Now we need to take care of the needs of some scripts that may not know the data has been moved.
> ln -s /home/databases/ /var/lib/mysql
> chown mysql:mysql /var/lib/mysql

Finally we can restart Mysql. Type the follwoing:
> service mysqld start

Conclusion

Enjoy

Comments

Retrieved from http://www.campworld.net/thewiki/pmwiki.php/Linux/MoveMysqlHOWTO
Page last modified on November 20, 2008, at 08:26 AM