How to recover just deleted rows in mysql?

前端 未结 8 804
长情又很酷
长情又很酷 2020-12-01 04:24

Is it possible to restore table to last time with data if all data was deleted accidentally.

相关标签:
8条回答
  • 2020-12-01 04:49

    No this is not possible. The only solution will be to have regular backups. This is very important.

    0 讨论(0)
  • 2020-12-01 04:57

    As Mitch mentioned, backing data up is the best method.

    However, it maybe possible to extract the lost data partially depending on the situation or DB server used. For most part, you are out of luck if you don't have any backup.

    0 讨论(0)
  • 2020-12-01 04:58

    If you use MyISAM tables, then you can recover any data you deleted, just

    open file: mysql/data/[your_db]/[your_table].MYD

    with any text editor

    0 讨论(0)
  • 2020-12-01 05:00

    I'm sorry, bu it's not posible, unless you made a backup file earlier.

    EDIT: Actually it is possible, but it gets very tricky and you shouldn't think about it if data wasn't really, really important. You see: when data get's deleted from a computer it still remains in the same place on the disk, only its sectors are marked as empty. So data remains intact, except if it gets overwritten by new data. There are several programs designed for this purpose and there are companies who specialize in data recovery, though they are rather expensive.

    0 讨论(0)
  • 2020-12-01 05:05

    For InnoDB tables, Percona has a recovery tool which may help. It is far from fail-safe or perfect, and how fast you stopped your MySQL server after the accidental deletes has a major impact. If you're quick enough, changes are you can recover quite a bit of data, but recovering all data is nigh impossible.

    Of cours, proper daily backups, binlogs, and possibly a replication slave (which won't help for accidental deletes but does help in case of hardware failure) are the way to go, but this tool could enable you to save as much data as possible when you did not have those yet.

    0 讨论(0)
  • 2020-12-01 05:07

    There is another solution, if you have binary logs active on your server you can use mysqlbinlog

    generate a sql file with it

    mysqlbinlog binary_log_file > query_log.sql
    

    then search for your missing rows. If you don't have it active, no other solution. Make backups next time.

    0 讨论(0)
提交回复
热议问题