Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongodb Atlas: not authorized on admin to execute command

I have a MongoDB Atlas cluster within which I am trying to simply copy a database within the same instance. Unfortunately, every time I try to run db.copyDatabase() or copydb admin command, I get the following error:

not authorized on admin to execute command

Which is very strange, because I just have one user, and it has access to everything, at least as far as I can tell on atlas:

enter image description here

I did some search in stackoverflow, but it looked like most of the answers pertain to mongod instances running locally, and not ones running in atlas... Did I setup the user wrong?

like image 670
Seaside9 Avatar asked Mar 04 '18 23:03

Seaside9


People also ask

Why is MongoDB not connecting to Atlas?

If you have created a user and are having trouble authenticating, try the following: Check that you are using the correct username and password for your database user, and that you are connecting to the correct database deployment. Check that you are specifying the correct authSource database in your connection string.

Is MongoDB Atlas no longer free?

It's easy to get started with MongoDB Atlas, and it's free.


2 Answers

I ended up asking this question to MongoDB University discussion board. In case anyone comes across this, this is apparently because I am using a free cluster.

like image 52
Seaside9 Avatar answered Oct 16 '22 12:10

Seaside9


I had the same issue when I was trying to connect to a cluster with Node.js version 3.0 or later and using the link below:

mongodb+srv://username:[email protected]/test?retryWrites=true

By selecting version 2.2.12 or later and using the link provided, everything went well

mongodb://username:[email protected]:27017,cluster0-shard-00-01-eoowo.mongodb.net:27017,cluster0-shard-00-02-eoowo.mongodb.net:27017/test?ssl=true&replicaSet=Cluster0-shard-0&authSource=admin&retryWrites=true

like image 22
dktistakis Avatar answered Oct 16 '22 10:10

dktistakis