MongoDB – Create Databases Without Access to Others

mongodb

I need two user accounts – both able to create and administer databases – but neither account able to access or administer databases created by the other account.

Is this possible?

Best Answer

Answer is NO. If user can create database what don't exists, user must have 'dbAdminAnyDatabase' role and then user can access any DB.

IF database names are know forehand, you can give 'dbAdmin' role to user for that database, even database don't actually exists yet. In this case, if those "prelisted" databases are different names, different users don't have right to those database what other users has created.

As you can create empty databases (without collections) forehand and give rights to users. But, DB names are "selected" forehand and user don't have possibility to choose their own DB name... Collections they can then create, if they have right to DB.