0

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.

Boyd
  • 723
  • 4
  • 15
  • 32
  • Any problem with importing it then performing a DROP on the tables? – Brad Christie Dec 19 '10 at 23:19
  • you mean DELETE FROM, he still wants the tables just not their content – jon_darkstar Dec 19 '10 at 23:24
  • Currently I'm using an shared hosting account, wich doesn't even allow me to execute an .sql file of this size. I don't want to also find an workaround for that and after that delete the data again. – Boyd Dec 19 '10 at 23:28
  • 1
    I think you're going to have to import the data dump locally and then export just the structure to another SQL dump file using `mysqldump -d -h localhost -u root -p thedatabase > dumpfile.sql` – stealthyninja Dec 19 '10 at 23:36
  • Of course that makes a lot of sense! Thank you! – Boyd Dec 19 '10 at 23:37

1 Answers1

1

@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
stealthyninja
  • 10,343
  • 11
  • 51
  • 59