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

dba.stackexchange https://dba.stackexchange.com/questions/16888

  •  22-10-2019
  •  | 
  •  

سؤال

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 !

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى dba.stackexchange
scroll top