How to move a MySQL database from one hard drive to another?

I am using MySQL 5.5 and MySQLWorkbench on Windows7. I have successfully created a database on my C: drive, but I want to move it to my E: drive. I stopped the mysqld daemon and edited my.ini to change datadir = "C: / ProgramData / MySQL / MySQL Server 5.5 / Data /" to datadir = "E: / MySQL / data /". I copied the data from location C: to location E :. I can start the mysqld process, but the created database does not appear. Can someone explain what I'm doing wrong?

+4
source share
4 answers

Since I wanted my innodb database to sit on a different partition, I stopped MySQL from MySQL Workbench. I copied my innodb ibdata1 database as well as 2 log files that MySQL automatically created in my C: \ ProgramData \ MySQL \ folder to a new folder on my E: section. I added the following to my.ini:

innodb_data_home_dir = "E:/MySQL Data" 

Now, when I start my database, all changes have been made to ibdata1 on the E: drive.

0
source

Basically you want to copy all the contents into the old directory into the new directory. Make sure that you do not copy binlogs either (if they exist, they look like mysql-bin.001, etc., and also do not copy mysql-bin.index, because they contain a link to the real path to the old binary logs) . After that, you can restart the mysql daemon and log in to see the databases.

PS: not tested, but should work.

0
source

When I tried to move my database, I ran into a problem when the windows did not have the same permissions in the new data folder as the original. You can verify that the correct user (s) have access to the new folder by going to the folder properties and then selecting the security tab.

0
source

Flush your database to disk using this tool http://sourceforge.net/projects/mysqlbutool/ Then return it to a new server using this tool http://www.webyog.com/

-1
source

All Articles