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

  • 相关阅读:
    clion中配置glfw和glew
    oracle xe在centos下的安装(更)
    git服务搭建以及本地连接
    IDEA导入Maven多项目(Mac下)
    关于反射的学习理解
    MySQL安装及后续配置
    idea配置servlet记录,tmocat当服务器,学习
    mapper映射文件配置之select、resultMap、resultType
    mysql多表查询
    看看阿里员工分享的java知识
  • 原文地址:https://www.cnblogs.com/shengulong/p/7922508.html
Copyright © 2011-2022 走看看