简体   繁体   中英

Mysqldump creating a partial backup

I need to test a MySQL database in another server. But database is too big to export and import. Besides I only need some part of database to test.

Let's assume that database has 20 tables and I need to get last 10000 records from each table. How can I create a mysqldump for this situation ?

(Related: How to use mysqldump for a portion of a table? )

I found this solution. This dump can be done if all tables has id field. By ordering results by id, you can get results.

mysqldump --user=backup_user -p databasename 
   --where="1=1 ORDER BY id DESC LIMIT 10000" | gzip > /targetfolder/file.sql.gz

You can use mysqldump with --where condition.

For example:-

mysqldump -u [username] -p [dbname] {--opt} --where="true limit 10000" > dump.sql

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM