I am trying to secure my mongodb installation. I created a user as follows:
db.createUser(
{
user: 'username',
pwd: passwordPrompt(),
roles: [
{ role: "readWrite", db: "db1" },
{ role: "readWrite", db: "db2" }
]
})
I can connect by doing:
mongosh "mongodb://username@localhost"
However the following fails with the message Authentication failed.
:
mongosh "mongodb://username@localhost/db1"