Recently, I tried to dump data from a production database and import it locally in a development environment. I went through the normal process of dumping the data:
mysqldump database > database.sql
And importing it locally:
mysql database < database.sql
However, I quickly got a duplicate key error:
ERROR 1022 (23000) at line 1170: Can't write; duplicate key in table 'sys_tracking_archive'
After some looking, I discovered the “–insert-ignore” option:
mysqldump --insert-ignore > database.sql
The second attempt to import the data worked correctly. Alternatively, I could have replaced all instances of “INSERT” with “INSERT IGNORE” in the original SQL dump file.