Reputation: 34006
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?)
Upvotes: 2
Views: 1131
Reputation: 34006
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
Upvotes: 5
Reputation: 18459
You can use mysqldump with --where condition.
For example:-
mysqldump -u [username] -p [dbname] {--opt} --where="true limit 10000" > dump.sql
Upvotes: 3