Tuesday, October 15, 2013

How to migrate MySql data files to other folder/drive?

Let's say you have installed an application that make used of the mysql database and you have completed the installation in a particular folder/drive. Now, you wish to migrate the data storing location to other folder/drive. In order to migrate MySql data files location, below are the details steps :-

Environment
OS: Window 7 Enterprise
MySQL: MySQL version 5.6.12

Assumption
MySQL home directory : [MYSQL_HOME]
MySQL new data files directory : [NEW_DATA_FOLDER]

1. Shutdown MySQL database
2. Copy the "data" folder that normally located at [MYSQL_HOME]\data to new data files directory, [MY_NEW_DATA], for example, "d:\data".
3. Open my.ini that located at [MYSQL_HOME]\my.ini
4. Edit the my.ini by changing the parameter as describe below:
datadir=[NEW_DATA_FOLDER]
5. Restart the MySql database server, that's it!

No comments: