2 / 2
Oct 2024

Dear Team,

I created a read only user on Mongodb community edition. However, its allowing the insert and update too. Please suggest what could have been wrong.

Below is the script i used to create read only user.

db.createUser(
{
user: “dbreaduser”,
pwd: “applebeetal”,
customData: {},
roles: [{ “role”: “readAnyDatabase”, “db”: “admin” }],
}
)

Hello! Welcome to the MongoDB community!

Are you trying to insert into the admin database?

Does your database have authentication and authorization enabled?

You can evaluate in the mongod.conf file in the security.authorization parameter.