0

I am running OS X with mySQL 8.0.22 running natively. A few weeks ago had to reinstall mySQL as I could not get it to start. I made a backup of all the folders under '/usr/local/mysql/data'.

When mySQL was installed again it had wiped all the databases.

The data inside these DB is in no way critical, but I remembered today I was working in a WordPress site with a page builder, hence all info is stored in the DB tables.

I would like to find a way to restore this database, but every article I have read mentions "ibd and frm" files.

There is not a single frm file from the backup I made.

Is there any way of recreating this DB at all or is it a lost cause?

Thanks!

4
  • .frm files just contain the table schema definition. If you have idb files without the frm files, you are essentially missing all of the metadata about table definitions. Do you have that metadata elsewhere? (Such as a source control system?) If so, there's this. – AMtwo Jan 2 at 8:47
  • Thanks, I followed that guide and it worked. I had no idea what the .frm files and you have clarified that, thank you! – csaborio Jan 2 at 12:54
  • PLEASE BE CAREFUL WITH THIS !!! MySQL 8.0 does not use .frm files. – RolandoMySQLDBA Jan 2 at 16:42
  • Ah, thanks Rolando, no wonder I did not have frm files! Yes, this could potentially cause all kinds of havoc, so it doesn't hurt to reinstate how careful one has to be these things! – csaborio Jan 2 at 23:04
1

As suggested by @AMtwo, .frm files contain the schema definition. Since these are WordPress tables, getting the schema was very easy as I had lots of installs to get this info from.

I then followed the guide at https://www.chriscalender.com/recovering-an-innodb-table-from-only-an-ibd-file/ and it worked just fine:

  1. Create table based on the schema of original table.
  2. Running ALTER TABLE product DISCARD TABLESPACE;
  3. Copying the original IBD file
  4. Running ALTER TABLE product IMPORT TABLESPACE;

The tutorial mentions further instructions but at this stage it simply worked for me. I did the same for all other tables, exported as SQL dump and imported successfully.

I would recommend using Docker + mySQL if you are going to be trying this out.

Thanks again @AMtwo, you pointed me in the right direction!

2
  • +1 for documenting the solution to the question. It would be nice if you mark it as the correct solution by accepting it. I beleive it takes 48 hours before you can do that. – Lennart Jan 2 at 14:08
  • 1
    Thanks Lennart, you are right, it will not me do that until tomorrow, I'll make a reminder :-) – csaborio Jan 2 at 23:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.