MySQL 5.6.26 误删ibdata恢复
[root@hank-yoon ~]# ps -ef | grep mysql
root 1129 1 0 15:30 pts/0 00:00:00 /bin/sh /export/servers/mysql/bin/mysqld_safe --datadir=/export/data/mysql/data/ --pid-file=/export/data/mysql/mysql.pid
mysql 2284 1129 2 15:30 pts/0 00:00:01 /export/servers/mysql/bin/mysqld --basedir=/export/servers/mysql --datadir=/export/data/mysql/data/ --plugin-dir=/export/servers/mysql/lib/plugin --user=mysql --log-error=/export/data/mysql/log/error.log --open-files-limit=65535 --pid-file=/export/data/mysql/mysql.pid --socket=/export/data/mysql/tmp/mysql.sock --port=3306
root 2343 1101 0 15:31 pts/0 00:00:00 grep mysql
[root@hank-yoon ~]# service mysql status
SUCCESS! MySQL running (2284)
[root@hank-yoon ~]# cd /export/data/mysql/data/
[root@hank-yoon data]# ls
a.sql binlog-rollback.pl c.sql ibdata1 ib_logfile0 ib_logfile2 mysql mysql-bin.000035 mysql-bin%Y%M%d.000001 performance_schema sakila yoon
auto.cnf b.sql hank ibdata2 ib_logfile1 modify.pl mysql-bin.000034 mysql-bin.index mysql-bin%Y%M%d.index rollback.pl test
[root@hank-yoon data]# rm -rf ibdata1 ibdata2
注意:无备份,误删ibdata文件,数据库千万不要重启,否则神仙下凡都没用了!
[root@hank-yoon data]# ps -ef | grep mysql
root 1129 1 0 15:30 pts/0 00:00:00 /bin/sh /export/servers/mysql/bin/mysqld_safe --datadir=/export/data/mysql/data/ --pid-file=/export/data/mysql/mysql.pid
mysql 2284 1129 1 15:30 pts/0 00:00:01 /export/servers/mysql/bin/mysqld --basedir=/export/servers/mysql --datadir=/export/data/mysql/data/ --plugin-dir=/export/servers/mysql/lib/plugin --user=mysql --log-error=/export/data/mysql/log/error.log --open-files-limit=65535 --pid-file=/export/data/mysql/mysql.pid --socket=/export/data/mysql/tmp/mysql.sock --port=3306
root 2362 1101 0 15:32 pts/0 00:00:00 grep mysql
[root@hank-yoon data]# ll /proc/2284/fd | egrep 'ib_|ibdata'
lrwx------. 1 root root 64 Jul 12 15:35 10 -> /export/data/mysql/data/ib_logfile0
lrwx------. 1 root root 64 Jul 12 15:35 11 -> /export/data/mysql/data/ib_logfile1
lrwx------. 1 root root 64 Jul 12 15:35 12 -> /export/data/mysql/data/ib_logfile2
lrwx------. 1 root root 64 Jul 12 15:35 4 -> /export/data/mysql/data/ibdata1 (deleted)
lrwx------. 1 root root 64 Jul 12 15:35 9 -> /export/data/mysql/data/ibdata2 (deleted)
锁表,禁止再写入数据,以便恢复工作
[root@hank-yoon data]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.26-log Source distribution
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
root((none))> flush table with read lock;
Query OK, 0 rows affected (0.00 sec)
root((none))>
不能停业务,锁表后刷脏页
root((none))> flush table with read lock;
Query OK, 0 rows affected (0.00 sec)
root((none))> set global innodb_max_dirty_pages_pct=0;
Query OK, 0 rows affected (0.00 sec)
通过show mater status确定file和position不再变化
root((none))> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000035 | 120 | | | |
+------------------+----------+--------------+------------------+-------------------+
通过root((none))> show engine innodb status\G查看是否还有写入
TRANSACTIONS
------------
Trx id counter 59143
Purge done for trx's n:o < 58676 undo n:o < 0 state: running but idle
##确保后台Purge进程把undo log全部清除掉,事务ID要一致
History list length 462
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0, not started
MySQL thread id 1, OS thread handle 0x7f5cec6eb700, query id 9 localhost root init
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 0, seg size 2, 0 merges
# insert buffer合并插入缓存等于1
merged operations:
insert 0, delete mark 0, delete 0
discarded operations:
insert 0, delete mark 0, delete 0
Hash table size 2365241, node heap has 0 buffer(s)
0.00 hash searches/s, 0.00 non-hash searches/s
---
LOG
---
Log sequence number 14149940429
Log flushed up to 14149940429
Pages flushed up to 14149940429
Last checkpoint at 14149940429
#三个值相同
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 1098907648; in additional pool allocated 0
Dictionary memory allocated 59957
Buffer pool size 65528
Free buffers 65118
Database pages 410
Old database pages 0
Modified db pages 0
#确保脏数据为0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 410, created 0, written 5
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 410, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
0 read views open inside InnoDB
Main thread process no. 2284, id 140037101377280, state: sleeping
Number of rows inserted 0, updated 0, deleted 0, read 0
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
#确保插入,更新,删除为0
再次找到这几个文件,恢复
[root@hank-yoon data]# ll /proc/2284/fd | egrep 'ib_|ibdata'
lrwx------. 1 root root 64 Jul 12 15:35 10 -> /export/data/mysql/data/ib_logfile0
lrwx------. 1 root root 64 Jul 12 15:35 11 -> /export/data/mysql/data/ib_logfile1
lrwx------. 1 root root 64 Jul 12 15:35 12 -> /export/data/mysql/data/ib_logfile2
lrwx------. 1 root root 64 Jul 12 15:35 4 -> /export/data/mysql/data/ibdata1 (deleted)
lrwx------. 1 root root 64 Jul 12 15:35 9 -> /export/data/mysql/data/ibdata2 (deleted)
[root@hank-yoon data]# cp /proc/2284/fd/4 /export/data/mysql/data/ibdata1
[root@hank-yoon data]# cp /proc/2284/fd/9 /export/data/mysql/data/ibdata2
修改权限
[root@hank-yoon data]# cd /export/data/mysql/data/
[root@hank-yoon data]# ls -ltr
total 4980844
drwx------. 2 mysql mysql 4096 Sep 30 2015 performance_schema
drwx------. 2 mysql mysql 4096 Sep 30 2015 mysql
-rw-rw----. 1 mysql mysql 56 Sep 30 2015 auto.cnf
drwx------. 2 mysql mysql 4096 Nov 18 2015 test
-rw-r--r--. 1 root root 15886 Dec 24 2015 binlog-rollback.pl
-rwxr-xr-x. 1 root root 2766 Jan 4 2016 modify.pl
-rw-r--r--. 1 root root 2766 Jan 5 2016 rollback.pl
drwx------. 2 mysql mysql 4096 Mar 22 21:54 hank
-rw-rw----. 1 mysql mysql 25 Apr 13 10:04 mysql-bin%Y%M%d.index
-rw-rw----. 1 mysql mysql 143 Apr 13 10:05 mysql-bin%Y%M%d.000001
-rw-rw----. 1 mysql mysql 268435456 Jun 21 10:07 ib_logfile1
drwx------. 2 mysql mysql 4096 Jun 21 15:02 sakila
drwx------. 2 mysql mysql 4096 Jun 29 14:50 yoon
-rw-r--r--. 1 root root 5087 Jun 29 14:53 a.sql
-rw-r--r--. 1 root root 124 Jun 29 14:55 b.sql
-rw-r--r--. 1 root root 47 Jun 29 14:56 c.sql
-rw-rw----. 1 mysql mysql 2027 Jul 12 15:30 mysql-bin.000034
-rw-rw----. 1 mysql mysql 120 Jul 12 15:30 mysql-bin.000035
-rw-rw----. 1 mysql mysql 38 Jul 12 15:30 mysql-bin.index
-rw-rw----. 1 mysql mysql 268435456 Jul 12 15:30 ib_logfile2
-rw-rw----. 1 mysql mysql 268435456 Jul 12 15:30 ib_logfile0
-rw-r-----. 1 root root 2147483648 Jul 12 15:55 ibdata1
-rw-r-----. 1 root root 2147483648 Jul 12 15:55 ibdata2
[root@hank-yoon data]# chown -R mysql.mysql ibdata1 ibdata2
重启登录数据库
[root@hank-yoon data]# service mysql restart
Shutting down MySQL.. SUCCESS!
Starting MySQL... SUCCESS!
[root@hank-yoon data]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.26-log Source distribution
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
root((none))>
MySQL 5.6.26 误删ibdata恢复的更多相关文章
- (4.10)mysql备份还原——利用binlog+全备恢复误删表【不推荐使用】
关键误操作:mysql误删除 1.备份+binlog恢复数据 [1.1]场景:不小心误删除某张表 [1.2]解决方法:在另外一台机器,恢复全库+日志,然后导出删除的表,再插入会生产库. [1.3]案例 ...
- mysql用户授权及数据备份恢复
用户授权与权限撤销 修改数据库管理员从本机登陆的密码测试: mysqladmin -hlocalhost -uroot -p password "新密码" Enter passwo ...
- MySQL日志管理、备份、恢复
目录: 一.MySQL 日志管理 二.数据库备份的重要性与分类 三.常见的备份方法 四.MySQL完全备份 五.数据库完全备份分类 六.MySQL增量备份 七.MySQL数据库增量恢复 八.MySQL ...
- mysql InnoDB通过.frm和.ibd恢复表和数据
ibdata1是一个用来构建innodb系统表空间的文件,这个文件包含了innodb表的元数据.撤销记录.修改buffer和双写buffer.如果file-per-table选项打开的话,该文件则不一 ...
- 技术分享 | 简单测试MySQL 8.0.26 vs GreatSQL 8.0.25的MGR稳定性表现
欢迎来到 GreatSQL社区分享的MySQL技术文章,如有疑问或想学习的内容,可以在下方评论区留言,看到后会进行解答 GreatSQL社区原创内容未经授权不得随意使用,转载请联系小编并注明来源. M ...
- [MySQL Reference Manual] 7 备份和恢复
7. 备份和恢复 本章主要会介绍: 1.备份的类型:逻辑备份,物理备份,全备和增量4种 2.创建备份的方法 3.还原方法,包括还原到时间点 4.备份计划,压缩和加密 5.表维护,恢复损坏的表 7. 备 ...
- Ubuntu 14 编译安装 PHP 5.4.45 + Nginx 1.4.7 + MySQL 5.6.26 笔记
Ubuntu 14 编译安装 PHP 5.4.45 + Nginx 1.8.0/1.4.7 + MySQL 5.6.26 笔记,主要是给自己的PC机安装,非生产环境! 一.下载必要的源码 1.1.下 ...
- Ubuntu 12 安装 MySQL 5.6.26 及 问题汇总
参考先前的文章:Ubuntu 14 编译安装 PHP 5.4.45 + Nginx 1.4.7 + MySQL 5.6.26 笔记 安装过程: #安装依赖库 sudo apt-get install ...
- 第五章 MySQL事务,视图,索引,备份和恢复
第五章 MySQL事务,视图,索引,备份和恢复 一.事务 1.什么是事务 事务是一种机制,一个操作序列,它包含了一组数据库操作命令,并且把所有的命令作为一个整体一起向系统提交或撤销操作请求.要么都执行 ...
随机推荐
- [Intermediate Algorithm] - Spinal Tap Case
题目 将字符串转换为 spinal case.Spinal case 是 all-lowercase-words-joined-by-dashes 这种形式的,也就是以连字符连接所有小写单词. 提示 ...
- Lazy Initialization with Swift
Lazy initialization (also sometimes called lazy instantiation, or lazy loading) is a technique for d ...
- IIS访问php页面问题,报告404错误
IIS访问php页面出现问题,所有php页面找不到,显示404页面,html页面可以正常访问. 搜索结果: 方案1: 打开WEB服务扩展,把“所有未知ISAPI扩展”设为允许! 方案2: PHP没有完 ...
- [luogu3627 APIO2009] 抢掠计划 (tarjan缩点+spfa最长路)
传送门 Description Input 第一行包含两个整数 N.M.N 表示路口的个数,M 表示道路条数.接下来 M 行,每行两个整数,这两个整数都在 1 到 N 之间,第 i+1 行的两个整数表 ...
- file_get_contens POST传值
<?php echo "<pre>"; print_r($_POST); print_r($_COOKIE); ?> 本文讲述的只是http post请求的 ...
- Linux安装expect命令
[Linux安装expect命令]:--expect是在Tcl基础上创建起来的,所以在安装expect前我们应该先安装Tcl.①:tcl安装源码下载:http://www.tcl.tk/softwar ...
- 最简单的tomcat安装部署
[安装环境] 适用于所有Linux操作系统,本人使用的是Centos 7.4 [安装] 浏览器登陆到tomcat官网 http://tomcat.apache.org/ 点击左侧需要下载的版本 右键图 ...
- Git学习总结(4)——我的Git忽略文件
*.bak *.txt *.vm .gitignore #svn .svn/ # built application files *.apk *.ap_ # files for the dex VM ...
- 关于struts值栈的总结,前端页面如何使用标签取得值栈中的数据
用户提交一次请求的执行过程 总结: struts值栈中 两个内容 一个是栈 一个是map 值栈(数据中心)的范围是一个请求 它代替了request作用域 struts自定义标签有一个特点 比如遍历集合 ...
- SSH框架整合截图(二)
客户拜访管理 1 什么是客户拜访 (1)客户:与公司有业务往来的 (2)用户:可以使用系统的人 2 用户和客户关系 (1)用户和客户之间是拜访的关系 (2)用户 和 客户 是 多对多关系 ** 一个用 ...