With mongoDB 4, is there any feature to disable the auto creation of collections/dbs? We need to disable the auto creation of collections/dbs in our mongo cluster, so that only defined db and collections should be available in our system
With mongoDB 4, is there any feature to disable the auto creation of collections/dbs?
Asked Answered
Turn on access control and then create a role with the appropriate restrictions.
What is the appropriate restrictions to disable auto creation of a collection ? –
Mcripley
See mongodb.com/docs/manual/reference/built-in-roles. Set your user up in readOnly role and they will not be able to create a collection. –
Xanthe
So... you're saying that disabling a user from creating data will disable their ability to have DBs and collections auto-created... That's like fixing a Windows 10 problem by uninstalling the OS. –
Terbia
It cannot be done at this time, per this: https://jira.mongodb.org/browse/SERVER-20679
There is no way to turn off auto-creation of collections and databases, but you could use the MongoDB authorization system to restrict only certain users/roles to have the ability to do so.
The last part about turning off their authorization, is of course obvious and unhelpful to the question being asked.
© 2022 - 2024 — McMap. All rights reserved.