Thesql dump best practices for development

MySQLmysqldump

I have an application that has a large database that includes, among many other tables, a table called content and a table called users.

I would like to set up a development environment for this application, however I would like to bring in only some parts of the content and users tables.

If there are 50,000 rows for each of these tables, I only want to bring over 10 rows so my development environment has at least some data.

What is the best way to create a dump of the database data and structure, while also limiting the size of the dump and the risk of putting sensitive information in a development environment?

Best Answer

mysqldump --opt --where="1 limit 10" database

It's an SQL injection: The --where option is basically appended to a query of the form SELECT * from table WHERE , so in this case you get SELECT * from table WHERE 1 limit 10. Without the 1, you would have an invalid query. Specifying 1 for a where clause (since 1 is always true) simply selects all records.

Source: Limiting the number of records from mysqldump?