How do I export the structure of a mysql database I have, keeping the structure for all the tables but only exporting the data for some of the tables? After exporting how do I import it into another mysql database on a different machine.

I can have the list of table names if it helps and I would prefer it if the solution will use command line but GUI is also acceptable (on windows).

Thanks

up vote 3 down vote accepted

1. To dump only table structures

a. dump

mysqldump -d -u root -p"password" --all-databases > /tmp/dumpfile.sql

b. restore

mysql -u root -p "password" "dbname" < /tmp/dumpfile.sql

2. To dump only data not structure

a. dump

mysqldump -uroot -p"password" --no-create-info "Db" "TableName"> /tmp/dumpfile.sql

b. restore

mysql -u root -p password "dbname" < /tmp/dumpfile.sql

3. To dump inserts only for specific Columns

a.dump

mysqldump -t -uroot -p"pawword" "Db" "TableName" --where =”Columnname in (1,2)” > /tmp/dumpfile.sql

b. Restore

mysql -u root -p password "dbname" < /tmp/dumpfile

Familiarize yourself with mysqldump command options, you will need to execute two sets of mysqldump backups, one for table structure only without data (--no-data) and another one that includes data for selected tables only.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.