Is it wrong to backup a MySQL DB through copying its data files (.frm, .MYD, etc.)?
I read somewhere that it is, so I was wondering开发者_如何学运维.
Don't do that, the .frm/.myd/.myi may be much larger than the actual data and may cause crash (data not consistence) or very hard to transfrom/recover.
Use mysqldump to transfer MySQL database.
It might or might not work, depending on the state of the data.
it should work if you stop the database completely and restart it again after the backup, but there you have a downtime.
A slightly more detailed response at askers request.
Some details of the dangers of a straight file copy:
- If the database is live the database might change some of the files before others so when you copy them you copy them you may get copies in that are inconsistent with each other. If the database is offline this method is probably reliable.
Advantages of using the documented methods:
- Should work on future version of DBMS
- Should work consistently across underlying engines
- Always a consistent snapshot like copy
精彩评论