MongoDB copyDatabase failed with dbOwner

mongodb

I have a remote mongo database in which I've setup a certain data base and a user with a dbOwner privileges.
I can access to this db with this user info, but I can not copy this data using copyDatabase.
I've read that a find access is required, but isn't that part of an owner access?
it's specifically mentioned in the documentation (http://docs.mongodb.org/manual/reference/built-in-roles/) that owner has all the admin rights, and admin has the find right.
but, when trying to call this function, I'm getting

"errmsg" : "exception: nextSafe(): { $err: \"not authorized for query on db1.system.users\",

For a reference, here is what getUser returns:

db.getUser('mu1')

{
"_id" : "db1.mu1",
"user" : "mu1",
"db" : "db1",
"roles" : [
{
"role" : "dbOwner",
"db" : "db1"
}
]
}

How can this happen to an owner of db1?

Thanks!

Best Answer

There are access requirements on both the source and target databases in order to be able to perform a copy. Assuming you are using 2.6 (which I think you are given that the dbOwner role was introduced in 2.6), the requirements are laid out in detail here (note: you should not use copyDatabase with roles in 2.4):

http://docs.mongodb.org/manual/reference/method/db.copyDatabase/#required-access

The copy actually runs on the target instance (the one you are copying to), so I'm guessing that is the issue here, that you do not have the correct permissions on the target host.

Related Topic