0

When i try creating user in mongodb or try to fetch users using getUsers(), i am said i am not authorised. I have freshly used a new --dppath.

> use admin;
switched to db admin
> db.getUsers();
2018-04-16T10:16:29.858+0530 E QUERY    [thread1] Error: not authorized on admin to execute command { usersInfo: 1.0 } :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.getUsers@src/mongo/shell/db.js:1537:1
@(shell):1:1

And similarly creating a user also throwing same permission issue.

couldn't add user: not authorized on admin to execute command { createUser: "myUserAdmin", pwd: "xxx", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ], digestPassword: false, writeConcern: { w: "majority", wtimeout: 600000.0 } } :

Do i need to uninstall the Mongodb in my windows machine now, because i already tried changing the --dbpath. If anyything wrong happens in configuration, i hope mongodb stores everything in this path(--dbpath) only and not anywhereelse.

Guys any knowhow??

Related stackoverflow resource : Creating first user in MongoDB 3.2.

Regards, Nilotpal

Nilotpal
  • 3,237
  • 4
  • 34
  • 56
  • A bit more than just "related". You are not authorized because you have not authenticated a user. And you can't create a "first" user because you already have a user created. I would strongly suggest you delete the current data files and start with the instructions again. You only get **one shot** at creating a "first" user with the "localhost exception" when you enable authentication on the database. – Neil Lunn Apr 16 '18 at 05:04
  • I agree. I had created a first user in mongodb. But now i am using a different --dbpath. Ideally I should have a new space now. What more do i need to clear for first user creation without uninstalling are reinstalling mongodb?? – Nilotpal Apr 16 '18 at 06:52

0 Answers0