HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMinor

How to recover MySQL table structure from FRM files

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
frmrecovermysqlfilesstructurehowfromtable

Problem

What I have learned from Google searching:

With MyISAM tables you can simply copy the FRM, MYD, and MYI files. In the folder for the DB I'm trying to recover, there are only FRM files and a "db.opt" file, so they must not be MyISAM tables.

Situation:

My computer crashed, but the data is still on the hard drive. The MySQL 5.5.8 server was installed with WAMP on the crashed computer.

I have tried copying the entire data folder over, but MySQL only creates a blank database - no tables.

There is an FRM file for each of the tables I wish to recover. However, they are not readable text files. Is there any way to recover the table structure from these files?

This post https://stackoverflow.com/a/7688688/1188138 indicates that the structure is in fact in those files, but does not provide a method of retrieval.

Thank you so much - I have tried everything I can think of.

Solution

If you only see the .frm files, then there is a strong likelihood that the storage engine in use was InnoDB and innodb_file_per_table must have been off by default.

If you transferred everything from datadir on the crashed server onto another disk on another machine, you may be able to startup mysql with that folder as is.

For example, suppose ServerA is your crashed server and ServerB is where you want it placed.

  • Install MySQL 5.5.8 on ServerB



  • net stop mysql on ServerB to make sure mysql is down on ServerB



  • md C:\MySQLData on ServerB



  • Drop everything from the data folder on ServerA into C:\MySQLData on ServerB



  • Make C:\MySQLData the new datadir



Add this to my.ini on ServerB

[mysql]
datadir=C:/MySQLData


  • C:\> del C:\MySQLData\ib_logfile* on ServerB



  • net start mysql on ServerB



Please try this and tell us what happened
UPDATE 2012-02-03 17:06 EDT

Since you were able to recover everything NOW DO THIS:

mysqldump -u... -p... -A -d --routines --triggers > C:\MySQLSchema.sql


This will give all table structures in the MySQL Instance.

Code Snippets

[mysql]
datadir=C:/MySQLData
mysqldump -u... -p... -A -d --routines --triggers > C:\MySQLSchema.sql

Context

StackExchange Database Administrators Q#12223, answer score: 4

Revisions (0)

No revisions yet.