Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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 !

share|improve this question

1 Answer 1

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.

share|improve this answer
    
Thanks Matt, This is a large dump and I cant replace the inserts. I was hopeing there is some option that I can give the mysql command prompt that tells it to ignore the errors. Most of the data is statistic so losing a few rows is OK. –  Nir Apr 23 '12 at 16:25
    
@Nir what do you mean by large -- lots of rows or lots of tables? You'll have to make one change for each table, regardless of number of rows. If you're only dumping one table, then you have to make one change. –  Matt Fenwick Apr 23 '12 at 16:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.