I was using the following script mounted on /docker-entrypoint-initdb.d/init-mongo.js to initialize my MongoDB 5.0DDBB on Docker:
db.auth("admin", "MyPassw0rd_123");
db = db.getSiblingDB("RecipientService");
db.createCollection('RecipientAggregate');
db.createUser({
user: "wfuser",
pwd: "MyPassw0rd_",
roles: [{
role: "readWrite",
db: "RecipientService"
}
]
});
However, it doesn't seems to work anymore with MongoDB 6.0, I'm getting the following message in DDBB logs:
MongoServerError: Authentication failed.
I can't find the right way to do it. I know the old mongo shell was deprecated in this version in favor of mongosh, maybe the syntax is not valid anymore, but I'm unable to find any advice after reading tons of docs.
Any clue about how to init a MongoDB 6.0 DDBB on Docker?