-1

I accidentally uninstalled my XAMPP and MySQL with InnoDB. How can I restore the files without having previously exported the database?

For some reason it didn't work just copying the old database files into the new database data directory.

I'm throwing this one out there for those in need, since it took me hours to fix, and it's quite easy once you know how. No cryptic SQL import commands or advanced shell commands are necessary.

Marcus Edensky
  • 924
  • 3
  • 13
  • 33
  • You could have simply searched the DBA site (this is not a programming issue after all, but an admin one), or SO (for whatever reason, people ask all kinds of IT related questions here) for a solution. It would be lot better if you add your dolution to one of the older questions in order to have the solutions in one place. – Shadow Aug 24 '18 at 08:50

1 Answers1

1

The database data is stored in C:\xampp\mysql\data\ or similar by default. The folders are the database tables. Inside each folder, the .frm file are the columns. The .ibd hold the row values.

First create the database(s) in PHPMyAdmin.

Get the SQL query generated from this site, under menu Recover structure > From .frm file:

https://recovery.twindb.com/

Upload each .frm file, and then copy and paste these queries into the SQL command to create the tables in PHPMyAdmin.

Then, on each table, do this SQL query:

ALTER TABLE table_name DISCARD TABLESPACE

This will automatically remove the new .ibd file from the database directory. Copy the old .ibd file into the database folder. Run the following command to activate the table again:

ALTER TABLE table_name IMPORT TABLESPACE

And that's it! You should be able to view and access all of your old values again.

Marcus Edensky
  • 924
  • 3
  • 13
  • 33