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
Asked
Active
Viewed 537 times
2 Answers
1
Turn on access control and then create a role with the appropriate restrictions.

Joe Drumgoole
- 1,268
- 9
- 9
-
What is the appropriate restrictions to disable auto creation of a collection ? – Omegaspard Dec 15 '22 at 11:22
-
See https://www.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. – Joe Drumgoole Dec 19 '22 at 10:59
-
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. – Ciabaros Aug 16 '23 at 17:31
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.

Ciabaros
- 1,984
- 13
- 15