MySQL database migration by copying data files
--Environment windows
Copy the source machine a database to the target machine B:
I first install MySQL on target machine B, stop the MySQL service, and then copy the files and ibdata1 from the source machine A to the database, and the rest is not copied. As shown in figure:
SOURCE Machine A:
Start the target database service net start MySQL to view all the databases that are being directed.
Note: Ibdata1 must not forget the copy, and to copy to the exact location (such as my target machine ibdata1 in E:\MySQL datafiles, not the data path, I will first back up its ibdata1, and then copy to the E:\MySQL datafiles) Otherwise the query copies the past table will have an error:
mysql> use platform;
Database changed
mysql> show tables;
+-----------------------+
| Tables_in_platform |
+-----------------------+
| mobile_scanner |
| sharer |
| sharer_mobile_scanner |
| Statistics |
| Test |
+-----------------------+
5 rows in Set (0.02 sec)
mysql> desc test;
ERROR 1146 (42S02): Table ' platform.test ' doesn ' t exist
Under Linux is similar to the way, but to note that after copying files, remember to change the data folder owner for MySQL.
Thank you for reading, I hope to help you, thank you for your support for this site!