Matej
Matej

Reputation: 9845

mongodb global authentication

I have set up a global admin with many roles such as clusterAdmin, any DB admin etc. However, I can only authenticate when inside the admin database.

For that reason, mongo -u admin -p does not work. I get auth fails error. However, when I just launch the mongo shell and then switch to the admin db and authenticate, it works.

mongo
> use admin
> db.auth('admin', <my password>)

What I want to do is

mongo
> db.auth('admin', <my password>)

How can I authenticate without having to use the admin db? Is there such a thing? I followed the mongodb documentation, read several guides and I can't seem to get this to work.

I want to use the mongodump to backup all databases, but it won't work because it cannot authenticate. Thanks

Upvotes: 1

Views: 403

Answers (1)

Matej
Matej

Reputation: 9845

Ok figured it out.. Using --authenticationDatabase admin works.

Upvotes: 2

Related Questions