大概看來幾篇博客:
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