Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using cloneCollection in MongoDB: how to authenticate?

Tags:

mongodb

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?

like image 425
thameera Avatar asked Feb 22 '14 18:02

thameera


People also ask

Does MongoDB have authentication?

MongoDB supports x. 509 certificate authentication for client authentication and internal authentication of the members of replica sets and sharded clusters.

What is the default authentication or access control state in MongoDB?

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.


1 Answers

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.

like image 122
Bruce Lucas Avatar answered Sep 18 '22 18:09

Bruce Lucas