![]() ![]() He can write into database db1, he cannot create or read any other database. By creating a role with privileges that are scoped to a specific collection in a particular database. Administrators can implement collection-level access control through user-defined roles. This commands creates the user and grant dbOwner of database db1. As per MongoDB documentation here Collection-level access control allows administrators to grant users privileges that are scoped to specific collections. Maybe you are looking for this: use admin This user can create any database, and he can write into any database.Įvery database provides built-In Roles read, readWrite, dbOwner, dbAdmin, userAdmin. Or db.getSiblingDB("admin").runCommand(.) Then above limitations apply.Ĭreate user in admin database and grant required roles: use admin ![]() Most likely you created it test database, which is the default. So, I assume user1 was not created in admin database. Roles which are created in other database than admin can only include privileges that apply to its database and can only inherit from other roles in its database.Ī role created in the admin database can include privileges that apply to any database or to the cluster resource, and can inherit from roles in other databases as well as the admin database. These roles are mainly related to replica set and sharded cluster administrative functions. The admin database includes roles for administering the whole system rather than just a single database. You can create users and roles in any database, however the admin database should be the common one. Users and roles are created in databases, I think that's a quite unique behavior for MongoDB. Database admin, config and local are pre-defined system databases. ![]() Maybe your problem is this: In MongoDB you have different databases. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |