Moving mysql files across servers

送分小仙女□ 提交于 2019-12-13 16:15:04

问题


I have a massive MySQL database (around 10 GB), and I need to copy it to a different server (slicehost). I don't want to do a DB dump and reimport b/c I think that would take forever. Is it possible to just move the raw SQL files from one machine to the next, setup an identical mysql server, and flip the switch?


回答1:


It should work.

This is the principle that the mysqlhotcopy tool uses, although this tool is meant to be run while the server is operating.




回答2:


Generally, yes. It's preferable to have the same underlying architecture and server version, but those aren't critically necessary. Make sure you stop the source server so that the raw files are a consistent copy.

I do this all the time when overwriting my dev database. We have backups on a replica that are made from tarring up /var/mysql when the server is stopped. I move those to another machine, overwrite iblog and ibdata, then overwrite all the directories in data except for mysql and test.




回答3:


You don't have a "massive" database, you have a smallish database at 10G. So dump/restore should not be a problem.

Copying the files directly might work in a subset of circumstances, but dump/restore is much better (i.e. less chance of problems).

Clearly, try it on a non-production system with the same version(s) of mysql and data size first to ensure that it's going to work on production.



来源:https://stackoverflow.com/questions/2859746/moving-mysql-files-across-servers

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!