恢复 mysql 备份 .myd .frm
我必须从 .myd 和 .frm 文件恢复 mysql 数据库。我不知道从哪里开始,我尝试在保留文件权限的同时复制它们,但无济于事,我还需要采取哪些其他步骤?
我感觉它与 ib_logfile0、ib_logfile1 和 ib_data 文件有关。但不知道该怎么办。
I am having to restore a mysql database from .myd and .frm files. And Ii have no idea where to begin, I tried just copying them over while preserving file permisssions but to no avail what other steps do i need to take?
I have a feeling its got something to do with the ib_logfile0, ib_logfile1 and ib_data files. But dont know what to do.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不应该通过处理原始 MySQL 文件来进行备份。这样很容易导致数据库损坏。考虑一下当您开始将文件复制到备份介质时会发生什么 - 复制将花费非零的时间,在此期间数据库可能会在各个位置写入新数据,包括您已经复制的部分。现在您正在复制修改后的文件,其中包含旧数据和新数据。这个修改过的副本几乎肯定会被损坏。
您应该改用 mysqldump 或 mysqlhotcopy,这可以保证备份的一致性。
但是,如果您的数据库相对安静并且您设法获得了良好的干净备份副本,则需要恢复的文件取决于要恢复的表的类型。 InnoDB 将其所有数据存储在 ib* 文件中,无论数据库/表名称如何。 MyISAM 使用根据数据库/表名称命名的目录中的文件。
将备份副本复制到正确的位置后,您必须重新启动 MySQL,因为它仍将访问文件的原始副本。
You shouldn't be doing backups by dealing with the raw MySQL files. It's trivially easy to end up with a corrupted database that way. Consider what happens when you start copying the files to your backup medium - the copy will take a non-zero amount of time, during which the database could potentially write new data in various places, including the parts you've already copied. Now you're copying a modified file, a mix of old data and new data. This modified copy is almost guaranteed to be corrupted.
You should be using mysqldump or mysqlhotcopy instead, which guarantee a consistent backup.
However, on the chance that your database is relatively quiet and you managed to get a good clean backup copy, the files you need to restore depend on the type of tables you're restoring. InnoDB stores all of its data in the
ib*
files, regardless of database/table name. MyISAM uses files in directories named according to the database/table names.After copying the backup copies into the correct locations, you'll have to restart MySQL, as it will still be accessing the original copies of the files.