Using cloneCollection in MongoDB: how to authenticate?

I am trying to clone a remotely hosted collection into my local Mongo database. I tried to open the mongo console in a local environment and issued:

db.runCommand({cloneCollection: "<dbname.colname>", from: "<remotehost:port>"}) 

Unable to complete

 "errmsg" : "exception: nextSafe(): { $err: \"not authorized for query on <dbname>.system.namespaces\", code: 16550 }", "code" : 13106, 

How to properly allow a remote server to clone a collection?

+8
mongodb
source share
1 answer

Unfortunately, this is currently not possible. There is a Jira ticket for this function. As a workaround, you can use mongodump --collection and mongorestore .

+7
source share

All Articles