Dump specific row with mysqldump

If you want to dump just certain rows of your table with mysqldump, you can perform the following command:

C:\\tmp>mysqldump \”–where=post_category=\’1\’\” -t dbname b2posts > dump.sql.txt

— dump.sql.txt —
# MySQL dump 8.16
# Host: localhost Database: dbname
# Server version 3.23.43-max-debug
# Dumping data for table \’b2posts\’
# WHERE: post_category=\’1\’

INSERT INTO b2posts VALUES (1,1,\’2003-01-22 23:21:38\’,\’This is the first post. Edit or delete it, then start blogging !\’,\’Hello world !\’,1,0);

Leaving attribute \”-t\” away, will add the table structure to the dump as well [1].

[1] http://www.mysql.com/doc/en/mysqldump.html

Leave a Reply