zoukankan      html  css  js  c++  java
  • 记录一下:关于mysql数据误删除恢复的问题

    大概看来几篇博客:

    1、delete的可以通过回滚(rollback)的方式恢复;但是前提是,你的数据表引擎是InnoDB而不是MyISAM,而且操作不是自动提交的

    但是这种方式不可以恢复truncate删除的数据

    mysql> show variables like '%autocommit%'
        -> ;
    +------------------------+-------+
    | Variable_name          | Value |
    +------------------------+-------+
    | autocommit             | ON    |
    | wsrep_retry_autocommit | 1     |
    +------------------------+-------+
    2 rows in set (0.00 sec)
    
    mysql> set autocommit=False;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> show variables like '%autocommit%'
        -> ;
    +------------------------+-------+
    | Variable_name          | Value |
    +------------------------+-------+
    | autocommit             | OFF   |
    | wsrep_retry_autocommit | 1     |
    +------------------------+-------+
    2 rows in set (0.00 sec)
    
    mysql>
    mysql> show table status from test where name='user';
    +------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+
    | Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time         | Update_time         | Check_time | Collation       | Checksum | Create_options | Comment |
    +------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+
    | user | MyISAM |      10 | Dynamic    |    5 |             20 |         144 | 281474976710655 |         3072 |        44 |              8 | 2017-01-11 18:03:54 | 2017-11-29 20:03:11 | NULL       | utf8_general_ci |     NULL |                |         |
    +------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+
    1 row in set (0.01 sec)
    
    mysql> mysql> show table status from test where name='tiger';
    +-------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-------------------+----------+----------------+---------+
    | Name  | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time         | Update_time | Check_time | Collation         | Checksum | Create_options | Comment |
    +-------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-------------------+----------+----------------+---------+
    | tiger | InnoDB |      10 | Compact    |    3 |           5461 |       16384 |               0 |            0 |         0 |             14 | 2017-01-09 16:45:03 | NULL        | NULL       | latin1_swedish_ci |     NULL |                |         |
    +-------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-------------------+----------+----------------+---------+
    1 row in set (0.00 sec)
    
    mysql>

    2、第二种方法就是利用mysql的bin-log进行恢复

    3、第三种方法,看你的数据库有没有定期备份机制,使用备份进行恢复

    记得要及时进行恢复操作,时间久了,bin-log和备份数据都会被删除的

    参考:

    1、http://blog.51cto.com/gfsunny/1573944

    2、https://www.cnblogs.com/dplearning/p/6394527.html

    3、http://blog.csdn.net/weiwangsisoftstone/article/details/68945420

    4、http://blog.csdn.net/u013803262/article/details/73044482

  • 相关阅读:
    在Linux下安装配置Oracle11g R2
    使用C#读取dbf行情文件
    终于完成了DailyBuild
    如何用NANT+FxCop 并生成文档规范检测结果?
    Nant中的一个小问题(可能让许多人急掉许多汗哦)
    最近在研究 Daily Build 不知道如何用CC.Net 得到 VSS改动的情况
    利用NAnt取得远程VSS服务器中的文件并且编译
    未曾秋高气爽,亦然爬山去也
    如何使用命令提示符下的FxCop
    在NAnt中加入Vssget 任务
  • 原文地址:https://www.cnblogs.com/shengulong/p/7922508.html
Copyright © 2011-2022 走看看