E
E
Evgeny Zapunny2022-04-11 11:49:50
MongoDB
Evgeny Zapunny, 2022-04-11 11:49:50

Why can't I access the db in mongoose?

Connected via shell to mogno, created a database with the use hotel command, then created a user

db.createUser({
    user: "name",
    pwd: "password",
    roles: [{ role: "userAdmin", db: "hotel" }],
});


After I connect to the database with this command

mongodb://name:[email protected]:port/hotel?authMechanism=SCRAM-SHA-1


I'm trying to create a new post but I get this error

MongoServerError: not authorized on hotel to execute command { insert: "hotels", documents: [ JSON ], ordered: true, lsid: { id: UUID("330df08b-c0d6-4900-9015-ce5da07d0bc1") }, $db: "hotel" },
//тут очень много строк я их вырезал
    at addChunk (node:internal/streams/readable:315:12) {
  ok: 0,
  code: 13,
  codeName: 'Unauthorized'
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question