Boyd
Boyd

Reputation: 763

Extract data dumps from .sql file

I've got an .sql file, it's an database backup from four years ago. This .sql file is filled with table creations but also data dumps. Because I actually don't need and want the data I'm looking for an way to extract all the data dumps from the .sql file. So that I'm only restoring the tables architecture.

I think the .sql file was generated by cPanel backup service.

Is there some automated way of doing this? I can't do it by hand because the .sql file has an enormous amount of lines.

Upvotes: 0

Views: 3472

Answers (1)

stealthyninja
stealthyninja

Reputation: 10371

@Boyd: Import the dump file locally using

mysqldump -d -h localhost -u root -p thedatabase > dumpfile.sql

Then export just the structure using

mysqldump -u username -p --no-data thedatabase > newdumpfile.sql

Upvotes: 1

Related Questions