Copying a database for testing in a safe way For testing purposes I have to create a copy of a production MySQL database that cannot be touched.

These are the steps I would follow:


Create a reduced size database backup:

mysqldump prodDB --single-transaction --where="true limit 20" &gt; test.sql
Create a new test database: testDB
Load the dump file in the new test database:

mysql testDB &lt; test.sql


Is this procedure correct?
Can I be sure that the original database will not be modified whatsoever?

Thank you!

System: MySQL 5.1 with InnoDB
Is this procedure correct ?


If you have no foreign key constraints, then yes this is correct.

If you have foreign key constraints, some data may be inaccessible. You would have to fix it.


  Can I be sure that the original database will not be modified whatsoever?


After the mysqldump do the following:

grep -c "DROP DATABASE" test.sql


If you get back 0, then yes the original database will not be modified whatsoever