Sample Header Ad - 728x90

for mongo, not able to create users other than admin with error command createUser requires authentication :

0 votes
2 answers
10816 views
This is the script I am using to create user accounts in MongoDB:
mongo <
This works for the creating first user, but not the second user. This is the error that is returned:
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("f648b868-7863-4d5c-9912-e3e87b24f4e8") }
MongoDB server version: 4.4.6
switched to db admin
Successfully added user: { "user" : "ram", "roles" : [ "root" ] }
uncaught exception: Error: couldn't add user: command createUser requires authentication :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1386:11
@(shell):1:1
bye
Asked by Acmakala Eesha (13 rep)
May 31, 2021, 04:27 AM
Last activity: Aug 1, 2025, 07:07 AM