I want to take a dump of a database, but the condition is to have only 100 records from each table in the DB?
Asked
Active
Viewed 6,426 times
1 Answers
9
I found a small hack for doing that in the MySQL manual (comment):
mysqldump -u [username] -p [dbname] {--opt} --where="true limit 100" > dump.sql

Lekensteyn
- 6,241
- 6
- 39
- 55
-
That's hideous and hilarious. Well-played. And here I was writing a script! – BMDan Aug 24 '10 at 10:26
-
People can be really creative in finding solutions :D Like that proverb, all roads lead to Rome. – Lekensteyn Aug 24 '10 at 10:29
-
I'm starting to believe that in shell every problem can be solved in one line. – Janne Pikkarainen Aug 24 '10 at 12:32
-
It's practically an SQL injection vulnerability of mysqldump CLI exploited for the good :D Well done – Darko Maksimovic Jan 29 '20 at 14:37