MongoError: Authentication failed

ServerSideSkittles

I am trying to setup an app with mongodb. I apparently need to

nano /etc/mongo.conf and uncomment "auth=true"

But there is no such setting, I have even checked /etc/mongod.conf and there is no auth=true in there.

So I was told to add user with userAdminAnyDatabase so I went in to the mongo shell and tried

db.createUser({ user: "username", pwd: "password", roles: ["userAdminAnyDatabase"] });

and I get

Error: couldn't add user: No role named userAdminAnyDatabase@test

All I want to do is either find my admin conn settings or just disable localhost auth altogether and get on with the installation.

Any ideas what im doing wrong?

Alex

You need to run this statement in the admin database, you are currently running it against the test database. Type in use admin in the Mongo shell to switch to the admin database. You also need to grant your user the readWriteAnyDatabase role.

db.grantRolesToUser(
 "username",
[
  { role: "readAnyDatabase", db:"admin" }
]
)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related