Hello, I have launched my mongodb using sudo systemctl start mongod which runs /usr/bin/mongod --config /etc/mongod.conf.
I have created a superuser user in my admin database:
admin> show users
[
{
_id: 'admin.superuser',
userId: new UUID("554176216d-5d9f-47ab-91c6-f0bf73ffb30asdc"),
user: 'superuser',
db: 'admin',
roles: [ { role: 'root', db: 'admin' } ],
mechanisms: [ 'SCRAM-SHA-1', 'SCRAM-SHA-256' ]
}
]
I am able to connect using mongosh "mongodb://localhost:27019/admin" -u superuser --authenticationDatabase admin and then giving “my_pw” (giving the wrong password fails).
After this setup, I add the following lines to my /etc/mongod.conf:
security:
authorization: "enabled"
and restart mongodb service with sudo systemctl restart mongod.
But then, the same password that worked before is not working anymore:
mongosh "mongodb://localhost:27019/admin" -u superuser --authenticationDatabase admin
“my_pw” fails, even though I just set it!
MongoNetworkError: connect ECONNREFUSED
Is there anything I’m missing here?