Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL InnoDB database restore

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.

Can anyone advise whether this is all I need to perform a database restore/import from the backup, or are there other files I should have to hand to complete this?

like image 678
Jaymie Thomas Avatar asked Sep 22 '08 15:09

Jaymie Thomas


People also ask

How do I restore an existing MySQL database?

In Database Explorer, right-click the server connection on which you want to restore the database and select Backup and Restore > Restore Database. In the Database Restore Wizard, select the backup file and click Restore.


2 Answers

.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.

like image 73
tpk Avatar answered Oct 25 '22 17:10

tpk


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

like image 35
3 revs, 2 users 94% Avatar answered Oct 25 '22 17:10

3 revs, 2 users 94%