Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make Database as ReadOnly in Mongo

Tags:

mongodb

Is there a way to convert the Mongo database as readonly on the primary node and on all other secondary nodes?

Like in SQL Server, we can alter database like this:

 alter database set readonly
like image 287
kishore Avatar asked Jun 19 '26 15:06

kishore


1 Answers

There could be 2 ways to achieve this.

  • Connecting to secondary directly instead of primary, not as part of the replica set, then it will behave as read only access.

  • Or turn on authentication and create read-only users.

like image 54
mhasan Avatar answered Jun 21 '26 17:06

mhasan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!