Mysql5.7数据恢复

工作中遇到服务器出现故障,Mysql程序出现故障无法启动,庆幸data中的数据还在。本文介绍如何通过data中的数据文件恢复Mysql的数据

在这里插入图片描述

1、重新安装Mysql,建议5.7+的版本,恢复起来更方便
2、在新的数据库中创建同样的数据库及对应的表(相信这个在测试库会有同样的表,导出一份脚本就行了,如果没有就麻烦了)
3、利用navicat工具连接新库,执行脚本删除新库中的ibd文件

# 分离表空间文件
alter table biz_medal_item                  discard tablespace;
alter table biz_medal_wall                  discard tablespace;
alter table biz_run_data                    discard tablespace;
alter table biz_sport_index                 discard tablespace;
alter table biz_sport_input                 discard tablespace;
alter table biz_step_detail                 discard tablespace;
alter table biz_user_configuration          discard tablespace;

执行完这个命令就会发现新库中的ibd文件都没了

4、然后将旧库中ibd文件拷贝到新库的对应目录下执行导入表空间命令

# 分离表空间文件
alter table biz_medal_item                  import tablespace;
alter table biz_medal_wall                  import tablespace;
alter table biz_run_data                    import tablespace;
alter table biz_sport_index                 import tablespace;
alter table biz_sport_input                 import tablespace;
alter table biz_step_detail                 import tablespace;
alter table biz_user_configuration          import tablespace;

如果执行过程中出现row_format不正确的报错信息根据实际情况执行
alter table report_active row_format=DYNAMIC;
alter table report_active row_format=COMPACT;
然后重新执行上面的命令

至此基本就能完成数据库的恢复工作了
注意:此文档是针对Mysql5.7+的恢复方法,本人用的就是5.7。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值