mongorestore "E11000 duplicate key error collection"
-
During the restore of a MongoDB based database, you may receive the error message
E11000 duplicate key error collection
This is because by default the
mongorestore
command does not drop existing collections before attempting to recover them, which results in the above error message as the collections already existAs an example, the command of
sudo mongorestore -d sudonixdev /path/to/database/sudonix -u admin -p <password> --authenticationDatabase=admin
Would need to become
sudo mongorestore --drop -d sudonixdev /path/to/database/sudonix -u admin -p <password> --authenticationDatabase=admin
The addition of
--drop
allows the collections to be overwritten by the restore. -
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (ether email, or push notification). You'll also be able to save bookmarks, use reactions, and upvote to show your appreciation to other community members.
With your input, this post could be even better 💗
RegisterLog in
1/1