Chapter 2 Replication error in creating user

In lab Deploy a Replica Set I rtried to connect when i connect with the primary node
Captura

db.createUser({
...   user: "m103-admin",
...   pwd: "m103-pass",
...   roles: [
...     {role: "root", db: "admin"}
...   ]
... })

But I can not create the new item because i got unauthorized.

2022-05-16T19:41:51.920+0000 E QUERY    [js] Error: couldn't add user: not authorized on test to execute command { createUser: "m103-admin", pwd: "xxx", roles: [ { role: "root", db: "admin" } ], digestPassword: true, writeConcern: { w: "majority", wtimeout: 600000.0 }, lsid: { id: UUID("eb5e59c9-473d-4425-95b9-15e41fe4dae9") }, $clusterTime: { clusterTime: Timestamp(1652730068, 5), signature: { hash: BinData(0, CD6914DF77B3322B4004DEBC45068D4E9494E85E), keyId: 7098421591175856129 } }, $db: "test" } :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1491:15
@(shell):1:1

Switch to admin DB and try again

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.