重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2774|回复: 0
打印 上一主题 下一主题

MYSQL 基于时间点的恢复

[复制链接]
跳转到指定楼层
楼主
发表于 2014-11-16 15:26:35 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
 基于时间点的恢复,是可以后悔已经提交的数据。
使用条件必须先开启二进制日志,最好不要开启企业监视器,因为如果开启企业监视器,会不停的查询数据库,会造成恢复失败。


恢复的语法:
(root@localhost) [test]> show binlog events in 'PC2014101864-bin.000002'\G
*************************** 1. row ***************************
   Log_name: PC2014101864-bin.000002
        Pos: 4
 Event_type: Format_desc
  Server_id: 1
End_log_pos: 120
       Info: Server ver: 5.6.21-enterprise-commercial-advanced-log, Binlog ver:
4
*************************** 2. row ***************************
   Log_name: PC2014101864-bin.000002
        Pos: 120
 Event_type: Query
  Server_id: 1
End_log_pos: 236
       Info: use `test`; DROP TABLE `upl` /* generated by server */
*************************** 3. row ***************************
   Log_name: PC2014101864-bin.000002
        Pos: 236
 Event_type: Query
  Server_id: 1
End_log_pos: 352
       Info: use `test`; create table upl(id int, user varchar(16))
*************************** 4. row ***************************
   Log_name: PC2014101864-bin.000002
        Pos: 352
 Event_type: Query
  Server_id: 1
End_log_pos: 468
       Info: use `test`; DROP TABLE `upl` /* generated by server */
*************************** 5. row ***************************
   Log_name: PC2014101864-bin.000002
        Pos: 468
 Event_type: Query
  Server_id: 1
End_log_pos: 584
       Info: use `test`; create table upl(id int, user varchar(16))
*************************** 6. row ***************************
   Log_name: PC2014101864-bin.000002
        Pos: 584
 Event_type: Query
  Server_id: 1
End_log_pos: 663
       Info: BEGIN
*************************** 7. row ***************************
   Log_name: PC2014101864-bin.000002
        Pos: 663
 Event_type: Query
  Server_id: 1
End_log_pos: 791
       Info: use `test`; insert into upl values (1,'tom'),(2,'mary'),(3,'bean')
*************************** 8. row ***************************
   Log_name: PC2014101864-bin.000002
        Pos: 791
 Event_type: Xid
  Server_id: 1
End_log_pos: 822
       Info: COMMIT /* xid=124 */
8 rows in set (0.00 sec)

(root@localhost) [test]>


查看当前那些点上,做了哪些操作。

然后找到相应的pos 进行恢复。
F:\mysql-advanced-5.6.21-winx64\data>mysqlbinlog --start-position=763 PC20141018
64-bin.000001 | mysql -u root -p

则会恢复跳过误操作。直接到最新的。



分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-4-29 21:11 , Processed in 0.082747 second(s), 20 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表