With mongoDB 4, is there any feature to disable the auto creation of collections/dbs?
Asked Answered
R

2

4

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

Reconvert answered 16/5, 2020 at 17:55 Comment(0)
X
1

Turn on access control and then create a role with the appropriate restrictions.

Xanthe answered 16/5, 2020 at 21:44 Comment(3)
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
T
0

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.

Terbia answered 16/8, 2023 at 17:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.