Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongodb returns unauthorized on copydatabase

Tags:

mongodb

I am logged with a user that has readWriteAnyDatabase, dbAdminAnyDatabase, userAdminAnyDatabase, clusterAdmin but still can not copy database. I am able to access and create collections in both databases individually.

> use admin
> db.auth('user', 'password')
> db.copyDatabase('database1', 'database2')
{ "ok" : 0, "errmsg" : "unauthorized" }

Mongodb version is 2.4.5

like image 933
Rajiv Avatar asked Jul 26 '13 13:07

Rajiv


People also ask

What happened to the copydb command in MongoDB?

Starting in version 4.2, MongoDB removes the copydb command. The deprecated db.copyDatabase (), which wraps the copydb command, can only be run against MongoDB 4.0 or earlier versions. For behavior and examples, refer to the 4.0 or earlier version of the manual. For an alternative in version 4.2+, see Copy/Clone a Database.

How to initiate a replica set in MongoDB Enterprise?

MongoDB Enterprise m103-repl:PRIMARY> use admin MongoDB Enterprise m103-repl:PRIMARY> db.auth ("m103-admin","m103-pass") Then try initiating the replica set. And if it is already initialised, check its status using:

Why is my MongoDB Compass running with an error?

You may see an error in MongoDB Compass similar to the following: The most common source of this error is a missing Atlas IP whitelist entry for the public IP address where Compass is running. Ensure the public IP address where Compass is running is included in your Atlas project's IP whitelist.

Why is my MongoDB cluster closed after setup?

This error means that the connection to your MongoDB cluster was closed before the initial setup completed. You may see an error in MongoDB Compass similar to the following: The most common source of this error is a missing Atlas IP whitelist entry for the public IP address where Compass is running.


1 Answers

This one will not work currently.

There is a note in the source : at https://github.com/mongodb/mongo/blob/master/src/mongo/db/cloner.cpp line 704 "Note: doesn't work with authentication enabled, except as old-style users."

like image 163
attish Avatar answered Oct 01 '22 19:10

attish