How to restore a database from .ibd,.frm files

274 Views Asked by At

I have .opt, .ibd and .frm files. I was not able to restore it.

My xampp is not working. Facing some port issue.

So i copy and pasted the .ibd,.frm files to another xampp which is working but I received " #1932- Table doesnt exist in engine".

I want my stored procedures and tables in the specific database.

1

There are 1 best solutions below

0
gpgb On

I searched for days for a solution to Table 'table_name' doesn't exist in engine to no avail. I was able to restore my data as follows

Background : Running a web application on a raspberry PI, raspberry PI crashed, no backup of course, I rebuilt the OS but the mariadb service wouldnt restart

This method is not for the faint hearted and requires a good knowledge of SQL

  1. Create a Test Database (IE DB name Test)

2 Hex dump respective table's .frm file in original directory to identify the table column names

3 build SQL (text file) to create new table, note best guess with datatypes

4 Create new table in Database Test

5 Discard TableSpace

6 Copy in .ibd file (to Test database directory)

7 Import tablespace

8 Stop and restart the mysql service

9 If service doesnt restart, check err log, edit my file recovery status to say 3 from 0

10 Do SQL query to check data, unlikely to be 100% correct

11 If not 100% correct but readable, copy original .frm file over Test .frm file

12 Stop and restart mysql service

13 Use SQL Describe table_name to obtain original table structure

14 Delete Test database and recreate using steps 5-7

15 Select statement should now show good data

16 Create new production database

17 Create new_tablename select * from Test.new_tablename;

18 Repeat for all tables

Good luck