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?
views:
335answers:
3
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
2009-09-29 17:24:28
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
2009-09-29 18:53:04
Thank you all. It seems like, there is no other way but to manually truncate each table after restoring it.
Nore
2009-09-29 19:34:07
I forgot to add that there are constraints on many tables avoiding any truncate on those tables.
Nore
2009-09-29 20:34:35
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
2009-09-29 18:53:27