You can dump part of a table using the mysqldump in command line.  The command is…

mysqldump -t -u [USERNAME] -p [SCHEMA] [TABLE] --where="[WHERE_CLAUSE]" > /your/file/location/dump.sql

The “-t” flag will suppress the “DROP” and “CREATE” commands so you will be left with a clean “INSERT” statement that you can load where ever needed.

You can also use a shortcut for the “where” by using just a “w”…

mysqldump -t -u [USERNAME] -p [SCHEMA] [TABLE] --w="[WHERE_CLAUSE]" > /your/file/location/dump.sql

So, for example… if you want to dump only “dogs” from the table called “animals” in a schema called “shelter” where your username is “root,” you would execute this statement…

mysqldump -t -u root -p shelter dogs --w="species = dog" > /Users/fetchdesigns/dumps/dogs.sql
0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments