views:

335

answers:

3

Hi I use mysql administrator and have restored backup files (backup.sql). I would like to use restore the structure without data and it is not giving me an option to do so. I understand phpadmin provides this. I can not use this however. Any one can tell me an easy way?

A: 

IIRC the backup.sql files (if created by mysqldump) are just SQL commands in a text file. Just copy-paste all the "create ..." statements from the beginning of the file, but not the "insert" statements in to another file and "mysql < newfile" you should have the empty database without any data in it.

Kimvais
A: 

there is no way to tell the mysql client to skip the INSERT commands. the least-hassle way to do this is run the script as-is and let it load the data, then just TRUNCATE all of the tables.

longneck
Thank you all. It seems like, there is no other way but to manually truncate each table after restoring it.
Nore
I forgot to add that there are constraints on many tables avoiding any truncate on those tables.
Nore
A: 

you can write a script to do the following:

1 : import the dump into a new database.

2 : truncate all the tables with a loop.

3 : export the db again.

4 : now u just have the structure

Sabeen Malik