Mongoerror parsing server authentication error

I configure the local parser, it works fine, except when I enable authentication in MongoDB and change the connection string to mongodb://username: password@localhost :27017/dbname , the parsing console gives the following error:

unable to ensure uniqueness for usernames mongoerror authentication failed

The client, i.e. RoboMongo, works great with authentication. I even tried with a user who was assigned the roles of userAdminAnyDatabase and dbAdminAnyDatabase to ensure that this is not a permission issue.

Update: I used MongoDB 3.2, so I tried to upgrade to MongoDB 3.0.12, still the same problem.

Update 2: I even tried the root role, which has the highest privilege, i.e. superuser, but still no luck.

+5
source share
1 answer

Have you created a user for a specific database? If you try to connect using the mongo admin account, you can experience this.

Create the user as follows:

 use dbName db.createUser({ user: "userName", pwd: "password", roles: [ "readWrite", "dbAdmin" ] }) 

and use it to connect to the database - then it should work

+4
source

All Articles