Skip to content

Instantly share code, notes, and snippets.

@phuysmans
Last active January 12, 2017 12:32
Show Gist options
  • Save phuysmans/e33371938462805e828acc1517ac320f to your computer and use it in GitHub Desktop.
Save phuysmans/e33371938462805e828acc1517ac320f to your computer and use it in GitHub Desktop.
undrop-from-innodb

https://mattstauffer.co/blog/restoring-lost-innodb-mysql-databases-after-all-data-and-hope-was-lost-with-drop-tables

https://twitter.com/twindba/status/637497047529078785

Hey guys, thanks for all your help!

I recovered the schema using your blog post: https://twindb.com/recover-table-structure-from-innodb-dictionary/

Then I re-ran the "Recovery from ibdata1" section of https://twindb.com/recover-innodb-table-after-drop-table-innodb/.

When it comes time to preview the output of the recovery (using command ./c_parser -6f pages-ibdata1/FIL_PAGE_INDEX/0000000000000493.page -t my-app/users.sql | head -5), it was still showing the same problem: some of my fields were overlapping...

Here's the schema:

CREATE TABLE `users`(
	`id` CHAR(36) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL,
	`name` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL,
	`email` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL,
	`password` VARCHAR(60) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci',
	`remember_token` VARCHAR(100) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci',
	`created_at` TIMESTAMP NOT NULL,
	`updated_at` TIMESTAMP NOT NULL,
	PRIMARY KEY (`id`)
) ENGINE=InnoDB;

But the output looks like this:

0000000066B3	290000019616EE	users	"07705153-26da-43b9-b62e-e5aa392ea671"	"Bob Schmobmyemails+bob+schmob@gmail."	"com$2y$10$"	"XPqlYdtCAqRbWgQX3zt/NuzKS15aN"	"k4bIBswHf9mCAwxkRgN9uEH2LIhrrAB3Hb5sJ88SQcCHWs14ABWFCOieeyuN"	"2024-05-18 21:17:58"	"2014-04-06 10:57:44"

As you can see, the first field (ID) is properly trimmed at 36 characters wide. But the second and third columns, which should varchar, are instead getting combined... and the second field is trimmed at 36 characters, regardless of how many fields are being crammed into it.

Then, the dates are clearly not getting imported correctly; the create dates on these are supposed to be in 2015, which tells me those fields are getting messed up too.

Do you have any ideas? At this point I've run out of ideas.

Thank you so much for all of your help. I couldnt' appreciate it more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment