Friday, November 18, 2011

How to recover mysql db from .myd, .myi, .frm files

One thing to note:
The .FRM file: Regardless of the storage engine you choose, every MySQL table you create is represented, on disk, by a .frm file, which describes the table's format (i.e. the table definition). The file bears the same name as the table, with a .frm extension. MySQL stores .frm files in datadir/database_name (If u don't know where is located your datadir then see your <mysql_install_dir>/my.ini file's #Path to the database root) .frm file is specific to your MySQL version.
The .MYD file is NOT specific to version, at least not minor versions.
The .MYI file is specific, but can be left out and regenerated with REPAIR TABLE.
Recover MySQL DB:
1. Create a dummy database (say vmdb)
2. Copy all these .myd, .myi, .frm files to mysql\data\abc wherein mysql\data\ is the place where .myd, .myi, .frm for all databases are stored.
3. Then go to phpMyadmin, go to db vmdb and you find your database!