0

I installed Locally on mac. Created user superuser with root privledges as per MongoDB Docs:https://docs.mongodb.com/guides/server/auth/#procedure

> db.createUser({user:"superuser",pwd:"strongPassword",roles:["root"]})
Successfully added user: { "user" : "superuser", "roles" : [ "root" ] }
> show users
{
    "_id" : "admin.superuser",
    "userId" : UUID("f873bafd-8d9b-4d2d-95a2-95d9e05db25d"),
    "user" : "superuser",
    "db" : "admin",
    "roles" : [
        {
            "role" : "root",
            "db" : "admin"
        }
    ],
    "mechanisms" : [
        "SCRAM-SHA-1",
        "SCRAM-SHA-256"
    ]
}

launch it with

resulting in running mongodb instance:

  "ctx":"listener","msg":"Waiting for connections","attr":{"port":27017,"ssl":"off"}}

then I mongo --port 27017 use admin response: switched to db admin here's the kicker: I input db.auth("superuser","strongPassword") and then

0```
This is the output in the running mongod client:
```{"t":{"$date":"2021-03-15T14:41:11.167-05:00"},"s":"I",  "c":"ACCESS",   "id":20251,   "ctx":"conn1","msg":"Supported SASL mechanisms requested for unknown user","attr":{"user":"superuser@admin"}}
{"t":{"$date":"2021-03-15T14:41:11.168-05:00"},"s":"I",  "c":"ACCESS",   "id":20249,   "ctx":"conn1","msg":"Authentication failed","attr":{"mechanism":"SCRAM-SHA-1","principalName":"superuser","authenticationDatabase":"admin","client":"127.0.0.1:51532","result":"UserNotFound: Could not find user \"superuser\" for db \"admin\""}}

Please help me? Seems pretty straightforward what my problem is here. Followed the mongoDb docs exactly, and then just totally failing to see my user. What's the trick here?

  • You have two mongodb servers and you created the user in one of them but are connecting to the other one, or you reset the entire database in between. – D. SM Mar 16 '21 at 00:49
  • Or you launched mongod with different db paths. – D. SM Mar 16 '21 at 00:50
  • How would I be able to connect to the original client with authentication, after Making the User? Mongodb docs just tell you how to start the server then leave you dead in the water as they move you to the next step. – Jon Atollah Mar 18 '21 at 17:53

0 Answers0