注意:以下演示过程前提为mysqld进程仍在运行中,否则无法使用下面演示过程进行恢复!

1.手工制造故障,删除ibdata1文件,注意不要重启mysql

shell > rm -rf ibdata1

2.登录mysql,进行如下操作

mysql > FLUSH TABLES WITH READ LOCK;  #全局加读锁,阻塞Innodb继续写入数据

mysql > SHOW engine innodb STATUS; #查看innodb status中的LSN位置

#找到这2个关键值

Log sequence number 1626744

Last checkpoint at  1626744

1)如果相减为0,则表示写入到磁盘中

#如果不为0,可以加速写入

mysql > SET global innodb_max_dirty_pages_pct=0;

2)同时要保证

INSERT BUFFER AND ADAPTIVE HASH INDEX

-------------------------------------

Ibuf: size 1, free list len 0, seg size 2, 0 merges

insert buffer thread. ibuf的大小应该=1

3) purge thread,它應該purge了全部的transactions

------------

TRANSACTIONS

------------

Trx id counter 14085

Purge done for trx's n:o < 0 undo n:o < 0 state: running but idle

4)确保innodb不在进行写操作

SHOW engine innodb STATUS

--------

FILE I/O

--------

I/O thread 0 state: waiting for completed aio requests (insert buffer thread)

I/O thread 1 state: waiting for completed aio requests (log thread)

I/O thread 2 state: waiting for completed aio requests (read thread)

I/O thread 3 state: waiting for completed aio requests (read thread)

I/O thread 4 state: waiting for completed aio requests (read thread)

I/O thread 5 state: waiting for completed aio requests (read thread)

I/O thread 6 state: waiting for completed aio requests (write thread)

I/O thread 7 state: waiting for completed aio requests (write thread)

I/O thread 8 state: waiting for completed aio requests (write thread)

I/O thread 9 state: waiting for completed aio requests (write thread)

Pending normal aio reads: 0 [0, 0, 0, 0] , aio writes: 0 [0, 0, 0, 0] ,

ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0

Pending flushes (fsync) log: 0; buffer pool: 0

172 OS file reads, 5 OS file writes, 5 OS fsyncs

0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s

3. 确认无误之后,/proc/pid/fd中找出ibdata1文件,(这个pid是mysqld 的进程号,如下图:)

#将ibdata1对应的链接文件5拷贝过去改名

shell > cp /proc/6954/fd/5 /data/mysql3306/ibdata1

4. 更改权限

shell > chown -R mysql.mysql /data/mysql3306/ibdata1

5. 重启[已可以正常登陆]

shell > mysqladmin shutdown -S /tmp/mysql3306.sock

shell > /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf start 3306

shell > mysql -uroot -S /tmp/mysql3306.sock

误删ibdata1文件恢复方法的更多相关文章

  1. linux下rm -r误删NTFS文件恢复方法

    一时疏忽,手一抖,把整个挂载的F盘删了一半!顿时傻眼!! 被删的F盘是Windows下NTFS分区,在Ubuntu12.04中挂载了F盘,使用rm命令时粗心大意,误删了一半的数据. 血的教训告诉我们, ...

  2. Mysql误删表中数据与误删表的恢复方法

    由于头两天面试时被问了这样一个问题,如果某同事误删了某个表,你该怎么恢复? 当时想了一下,因为博主没有遇到过这个问题,但是也多少了解一些,所以就回答通过mysql的binlog日志进行恢复. 面试官当 ...

  3. Ubuntu 16.04使用rm -rf误删文件恢复方法收集

    说明:不一定有效,需要不断尝试 一.lsof 文件刚刚被删除,想要恢复,先尝试lsof. lsof |grep data.file1 cp /proc/xxx/xxx/xx /dir/data.fil ...

  4. 误删ext3的恢复方法

    1.Ext3文件系统结构的简单介绍在Linux所 用的Ext3文件系统中,文件是以块为单位存储的,默认情况下每个块的大小是1K,不同的块以块号区分.每个文件还有一个节点,节点中包含有文件所有者, 读写 ...

  5. 云服务器 ECS Linux 误删除文件恢复方法介绍

    云服务器 ECS Linux 下,rm -rf  意味着一旦删除的文件是无法挽回的.但如果在没有文件覆盖操作的前提下,可以先尝试相关方式进行文件恢复. 本文对此进行简要说明. https://help ...

  6. oracle数据库丢失数据文件、控制文件、重做日志文件、初始化文件恢复方法

    rman  target/ list backup; 查看是否已备份,如果没有,那就不知道了 模拟故障,删除/u01/app/oracle/oradata/ORCL文件夹下的所有文件 sqlplus ...

  7. SQL 恢复master数据库方法,没有log文件的数据库文件恢复方法

    SQL Server恢复master数据库方法 第一步:复制model.mdf.mastlog.ldf.model.mdf.modellog.ldf.msdbdata.mdf.msdblog.ldf文 ...

  8. linux下误删数据文件恢复

    linux下文件被删除能够用非常多工具进行恢复.比如undelete(适合ext2,ext3).giis(不能恢复安装giis之前的文件).ext3grep(仅限ext3).R-linux(支持ext ...

  9. mysql 数据库通过拷贝文件恢复方法

    MyIASM可以直接拷贝过去,就可以完成备份的还原 搭建与原数据库相同的的数据库环境(mysql版本一致) 将data文件夹下的文件复制到搭建的新数据库data文件夹下 删除数据库下的.ibd(数据文 ...

随机推荐

  1. WIN8 MTK驱动不能安装解决办法

    1.把鼠标移动到桌面最右下角的位置会出来一个侧边栏,按那个齿轮就是“设置”,会出来个菜单,选择最下边的“更多电脑设置” 注:也可以按快捷键“WIN+I” 2.选择“常规”→“高级启动”→”立即重启“ ...

  2. 关于JQuery设置checkbox checked 的问题

    近日做一个关于JQuery表单验证,有一个比较奇葩的要求,即checkbox是为必填项,textbox不是必填的. 而checkbox与textbox又是相关的,填写了textbox,则其上方的che ...

  3. div自定义的滚动条 (水平导航条)

    <!DOCTYPE html> <html> <head> <title></title> <style> div{ /* wi ...

  4. BizTalk开发系列(二十一) Mapping 扩展开发

    BizTalk Map编辑器提供了常用的功能块,比如数据库,字符串,数字计算等功能.可在设计Map时直接使用这些功能块进行扩展.除此之外对于进行复杂的Map处 理,Map 编辑器提供了扩展XSLT,扩 ...

  5. Apache模块mod_security 和 Nginx过滤配置

    1.安装mod_securityyum install mod_security 2.安装mod_security_crsyum install mod_security_crs 3.在/etc/ht ...

  6. (IOS)BaiduFM 程序分析

    本文主要分享下楼主在学习Swift编程过程中,对GitHub上的一个开源app BaiduFM的研究心得. 项目地址:https://github.com/belm/BaiduFM-Swift 一.项 ...

  7. MVC控制器取参数值

    1.这个方法是获取提交表单里的参数值,也就是有name="xxx"的属性的表单控件的值 FormCollection传值 public ActionResult Login(For ...

  8. 用Appium进行android自动化测试

    appium是开源的移动端自动化测试框架,可以测试ios,android应用.appium让移动端自动化测试不必限定在某种语言和某个具体的框架:也就是说任何人都可以使用自己最熟悉最顺手的语言以及框架来 ...

  9. c# word 转pdf 导出失败,因为此功能尚未安装

    savePDF应该是office2007以上的版本才支持的,而且必须是完整版的office. 如果2007提示这个错误,还需要安装一个插件 http://download.microsoft.com/ ...

  10. awk 合并文件

      问题描述:两个文件a.dat, b.dat a.dat 0    100 1    99 2    93 3    90 ... b.dat 0   0 1   3 2   0 3   2 ... ...