# MYSQLDUMP with where condition and date range

**URL:** <https://forums.percona.com/t/mysqldump-with-where-condition-and-date-range/1956>\
**Category:** Other MySQL® Questions\
**Created:** [December 27, 2012, 5:55am UTC](https://forums.percona.com/t/mysqldump-with-where-condition-and-date-range/1956 "2012-12-27T05:55:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhishekamralkar](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/abhishekamralkar/32/898_2.png) [@abhishekamralkar](https://forums.percona.com/u/abhishekamralkar)\
**Post date:** [December 27, 2012, 5:55am UTC](https://forums.percona.com/t/mysqldump-with-where-condition-and-date-range/1956/1 "2012-12-27T05:55:17Z")

</div>

I would like to take backup from a table for 6 months say in between date 1-july-2012 to 1-dec-2012 using mysqldump is it possible if yes please do let me know command.

---

<div class="post-metadata">

**Author:** ![miguelangelnieto](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@miguelangelnieto](https://forums.percona.com/u/miguelangelnieto)\
**Post date:** [December 27, 2012, 7:46am UTC](https://forums.percona.com/t/mysqldump-with-where-condition-and-date-range/1956/2 "2012-12-27T07:46:24Z")

</div>

Hi,

mysqldump has a “where” parameter where you can specify what data you want to dump.

[http://dev.mysql.com/doc/refman/5.5/en/mysqldump.html#option](http://dev.mysql.com/doc/refman/5.5/en/mysqldump.html#option) \_mysqldump\_where

So to do that your table should have a column with a timestamp/datetime datatype that could allow you to write a where clause and thus dumping only the data you need. For example:

mysqldump database table\_bame --where=“date\_column BETWEEN ‘2012-07-01 00:00:00’ and ‘2012-12-01 00:00:00’”

---

<div class="post-metadata">

**Author:** ![lorraine.pocklington](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/lorraine.pocklington/32/37_2.png) [@lorraine.pocklington](https://forums.percona.com/u/lorraine.pocklington)\
**Post date:** [April 8, 2020, 6:53am UTC](https://forums.percona.com/t/mysqldump-with-where-condition-and-date-range/1956/3 "2020-04-08T06:53:38Z")

</div>

This advice is still relevant and for MySQL 8.0&nbsp; 😛   
Updated manual page:&nbsp;[https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html#option\_mysqldump\_where](https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html#option_mysqldump_where "Link: https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html#option\_mysqldump\_where")&nbsp;   
Percona Server for MySQL offers extended functionality with mysqldump&nbsp;  
[https://www.percona.com/doc/percona-server/LATEST/flexibility/extended\_mysqldump.html](https://www.percona.com/doc/percona-server/LATEST/flexibility/extended_mysqldump.html "Link: https://www.percona.com/doc/percona-server/LATEST/flexibility/extended\_mysqldump.html")
