I'm trying to clone a remotely hosted collection to my local Mongo database. I tried opening up the mongo console in the local environment and issued:
db.runCommand({cloneCollection: "<dbname.colname>", from: "<remotehost:port>"})
It fails with
"errmsg" : "exception: nextSafe(): { $err: \"not authorized for query on <dbname>.system.namespaces\", code: 16550 }",
"code" : 13106,
How do I properly authorize with the remote server to clone the collection?
MongoDB supports x. 509 certificate authentication for client authentication and internal authentication of the members of replica sets and sharded clusters.
MongoDB does not enable access control by default. You can enable authorization using the --auth or the security. authorization setting. Enabling internal authentication also enables client authorization.
Unfortunately that's currently not possible. There is a Jira ticket open for this feature. As a workaround you could consider using mongodump --collection
and mongorestore
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With