Mysql:Need to upload data to database, get duplicate key error – how can dup keys be ignored

MySQLmysql-5.1mysqldump

I'm uploading data to a db (mysql 5.1.42) from a dump file using mysql command line and get duplicate key error.

This is the format I use:

/mnt/temp# mysql -u username -p -h url_of_db_master -D farm2 <
db_dump_part_file_a

Hoe can I tell mysql to ignore duplicate keys?

Thanks !

Best Answer

You'll have to decide what you want to happen when a duplicate is found, because you can:

Since mysqldump usually dumps each table in a single insert statement, you can easily just add those keywords in the dump file.

See this SO post for a more in-depth discussion on the pros and cons of the two possiblities.