MySQL InnoDB 数据库恢复
我必须恢复在 MySQL 5.0 中无意中删除的数据库。 通过检查备份文件,我似乎只有 .FRM 文件来保存数据库数据。
任何人都可以建议这是否是我从备份执行数据库恢复/导入所需的全部内容,或者我还需要提供其他文件来完成此操作吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
.frm 文件不是数据文件,它们只是存储“数据字典信息”(参见 MySQL 手册)。 InnoDB 将其数据存储在 ib_logfile* 文件中。 这就是您进行备份/恢复所需要的。 有关更多详细信息,请参阅此处。
.frm files are not the data files, they just store the "data dictionary information" (see MySQL manual). InnoDB stores its data in ib_logfile* files. That's what you need in order to do a backup/restore. For more details see here.
您可以在这里找到详细的解决方案:
http://www.unilogica.com/mysql-innodb- recovery/(葡萄牙文文章)
除了innodb_force_recovery标志之外,我找到了另一个解决方案:innodb_file_per_table,它像MyISAM表一样拆分每个文件中的InnoDB表。
在崩溃恢复中,与单个文件 ibdata1 相比,您丢失的数据要少。
The detailed solution you can found here:
http://www.unilogica.com/mysql-innodb-recovery/ (Article in Portuguese)
Besides the flag of innodb_force_recovery, I found another solution: innodb_file_per_table, that splits InnoDB tables in each file like MyISAM tables.
In a crash recovery you can lost less data than in single file ibdata1.
恢复innodb:
(假设您的数据文件夹为C:\ProgramData\MySQL\MySQL Server 5.5\data)
<块引用>
<前><代码>_ib_logfile0
_ib_日志文件1
_ibdata1
通过文件右键单击 -> 获取 _ib_logfile0 的大小(以 MB 为单位)(它应该与 _ib_logfile1 相同) 属性
编辑 mysql 配置文件 (mysql\bin\my.ini),使 innodb_log_file_size=343M 与 ibdata 文件大小完全相同
运行
<块引用>
mysqld --defaults-file=mysql\bin\my.ini --standalone --console
--innodb_force_recovery=6
运行
现在您的数据应该回到数据库中。 使用 phpmysql 或任何其他工具导出它们
Restoring innodb:
(assuming your data folder is C:\ProgramData\MySQL\MySQL Server 5.5\data)
Copy the 3 ibdata files to the data folder ex. (C:\ProgramData\MySQL\MySQL Server 5.5\data)
Get the size of the _ib_logfile0 in MB (it should be the same as _ib_logfile1) by File Right click -> Properties
Edit the mysql config file (mysql\bin\my.ini) for the innodb_log_file_size=343M to be exactly the ibdata files size
Run
Now your data should be back in your database. Export them using phpmysql or any other tool