Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restore the mysql database from .frm files

I have dumped all my tables everyweek to got the backup. But later I understand that it is only storing the .frm file of the table. It is not showing .MYD and .MYI files of a table. So I have only my .frm file of the database with me and also mydatabase is innodb. So can I get my database with data in the database?

like image 376
user359187 Avatar asked Jun 07 '12 15:06

user359187


People also ask

How do I read a .frm file in MySQL?

To open FRM file, we just need to double-click and let the software associated with it open it. Here the default software normally used is MySQL Database. MySQL Database is free to download and it supports multiple platforms.


2 Answers

Yes this is possible. It is not enough you just copy the .frm files to the to the databse folder but you also need to copy the ib_logfiles and ibdata file into your data folder. I have just copy the .frm files and copy those files and just restart the server and my database is restored.

After copying the above files execute the following command -

sudo chown -R mysql:mysql /var/lib/mysql

The above command will change the file owner under mysql and it's folder to MySql user. Which is important for mysql to read the .frm and ibdata files.

like image 164
user359187 Avatar answered Sep 28 '22 01:09

user359187


Just might be useful for someone:

I could only recover frm files after a disaster, at least I could get the table structure from FRM files by doing the following:

1- create some dummy tables with at least one column and SAME NAME with frm files in a new mysql database.

2-stop mysql service

3- copy and paste the old frm files to newly created table's frm files, it should ask you if you want to overwrite or not for each. replace all.

4-start mysql service, and you have your table structure...

regards. anybudy

like image 21
anybudy Avatar answered Sep 28 '22 00:09

anybudy