MySQL InnoDB database restore

后端 未结 4 1200
无人共我
无人共我 2020-12-29 12:17

I have to restore a database that has been inadvertently DROPped in MySQL 5.0. From checking the backup files, I only seem to have .FRM files to hold the database data.

相关标签:
4条回答
  • 2020-12-29 12:45

    The detailed solution you can found here:

    http://www.unilogica.com/mysql-innodb-recovery/ (Article in Portuguese)

    Besides the flag of innodb_force_recovery, I found another solution: innodb_file_per_table, that splits InnoDB tables in each file like MyISAM tables.

    In a crash recovery you can lost less data than in single file ibdata1.

    0 讨论(0)
  • 2020-12-29 12:47

    Oh my... you're in trouble. Shutdown the database. Backup the innodb file. Pray that you did NOTHING after you dropped the database.

    The guys at Percona (includes authors of MySQL Performance Blog) should be able to help you out: Percona emergency support.

    If you do venture on your own, take this with you: Data Recovery Toolkit for Innodb.

    The logistics of it? You have to read every page (the computer term page... 16k block in the case of Innodb) in and rebuild your data that way. It's very low-level work (we're talking open up your hex editor and start counting bytes if the toolkit doesn't do it for you), and if you're not a strongly experienced programmer, you're going to be hurting.

    0 讨论(0)
  • 2020-12-29 12:53

    .frm files are not the data files, they just store the "data dictionary information" (see MySQL manual). InnoDB stores its data in ib_logfile* files. That's what you need in order to do a backup/restore. For more details see here.

    0 讨论(0)
  • 2020-12-29 13:01

    Restoring innodb: (assuming your data folder is C:\ProgramData\MySQL\MySQL Server 5.5\data)

    1. Copy the folders of the databases (named after the database name) you want to restore to C:\ProgramData\MySQL\MySQL Server 5.5\data
    2. Copy the 3 ibdata files to the data folder ex. (C:\ProgramData\MySQL\MySQL Server 5.5\data)

      _ib_logfile0
      _ib_logfile1
      _ibdata1
      
    3. Get the size of the _ib_logfile0 in MB (it should be the same as _ib_logfile1) by File Right click -> Properties

    4. Edit the mysql config file (mysql\bin\my.ini) for the innodb_log_file_size=343M to be exactly the ibdata files size

    5. Run

      mysqld --defaults-file=mysql\bin\my.ini --standalone --console --innodb_force_recovery=6

    6. Now your data should be back in your database. Export them using phpmysql or any other tool

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