44.MySQL 基于文件句柄的恢复

1.插入数据但不提交。
mysql> start transaction;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into test6 values(4,'xsq');
Query OK, 1 row affected (0.00 sec)
2.[root@mysql1 mysql3306]# pidof mysqld
6655
3.删除文件。
[root@mysql1 mysql3306]# rm -rf ibdata1  ib_logfile0 ib_logfile1 ibtmp1 
[root@mysql1 mysql3306]# 
4.查看进程。
yum -y install net-tools 
netstat -ntlp|grep mysqld |grep 6655

5.查看句柄。
[root@mysql1 mysql3306]# ll /proc/6655/fd |grep delete
lrwx------. 1 root root 64 Feb 18 18:11 10 -> /mysql/mysql3306/ibdata1 (deleted)
lrwx------. 1 root root 64 Feb 18 18:11 11 -> /mysql/mysql3306/ibtmp1 (deleted)

lrwx------. 1 root root 64 Feb 18 18:11 12 -> /tmp/ibC3BHNg (deleted)
lrwx------. 1 root root 64 Feb 18 18:11 4 -> /mysql/mysql3306/ib_logfile0 (deleted)
lrwx------. 1 root root 64 Feb 18 18:11 5 -> /tmp/ibZtLFWn (deleted)
lrwx------. 1 root root 64 Feb 18 18:11 6 -> /tmp/ibIalAsm (deleted)
lrwx------. 1 root root 64 Feb 18 18:11 7 -> /tmp/ibNc7uYk (deleted)
lrwx------. 1 root root 64 Feb 18 18:11 8 -> /tmp/ibHGNj7h (deleted)
lrwx------. 1 root root 64 Feb 18 18:11 9 -> /mysql/mysql3306/ib_logfile1 (deleted)

10,11,9,4
cd ll /proc/6655/fd 

[root@mysql1 fd]# cp 10 /mysql/mysql3306/ibdata1
[root@mysql1 fd]# cp 11 /mysql/mysql3306/ibtmp1
[root@mysql1 fd]# cp 4 /mysql/mysql3306/ib_logfile0
[root@mysql1 fd]# cp 9 /mysql/mysql3306/ib_logfile1

chown -R mysql:mysql /mysql/mysql3306/* 
*/
systemctl stop mysql 
systemctl start mysql 

[root@mysql1 mysql]# mysql -uroot -prootroot 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases; 
+--------------------+
| Database           |
+--------------------+
| information_schema |
| jydb               |
| mysql              |
| performance_schema |
| sys                |
| test               |
| test2              |
+--------------------+
7 rows in set (0.00 sec)
mysql> select * from test6;
+----+------+
| id | name |
+----+------+
|  1 | xsq  |
|  2 | xsq  |
|  3 | xsq  |
发现还是原来的三条数据。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值