mysqldump -w "created_at > '2024-01-01'" mydb users > old_users.sql

Category: Databases & SQL

mysqldump -w "created_at > '2024-01-01'" mydb users > old_users.sql

Back up only rows matching a condition

-w (or --where) filters which rows are dumped; the condition is real SQL and must be quoted. Perfect for archiving old records. Related: --no-data, --single-transaction.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.