

Which permission should I assign to this user to be able to run aggregate?

A user with dbadmin or useradmin can admin the database (including granting yourself additional rights) but cannot perform queries or write data. You can configure a Custom Role in Atlas so that Database users associated with the custom role can only perform selected actions and roles against certain database(s). It's a bit confusing - I believe you will need to grant yourself readWrite to query a database. However, if these roles cannot describe the desired set of privileges, you can create new roles in a particular database. MongoDB provides a number of built-in roles that administrators can use to control access to a MongoDB system. I don’t want to let this user access other DBs. Roles grant users access to MongoDB resources. I would like to create custom policy with the least permission on the cluster. Have you tried the same command with the user who has permissions against database dbname? Since the same command works using as opposed to I suspect that the issue may exist with what database the command is being run against.
#MONGODB GRANT READWRITE HOW TO#
How to set up a user who doesn't have admin database access but use it as authentication database 3. In the roles field, you can specify both built-in roles and user-defined role. However, the error above indicates you are running the aggregate command against a different database name. MongoDB: Grant roles to multiple databases based on a pattern. You have stated originally that the user had the permission on the dbname database. MongoError: not authorized on mydb?retryWrites=true&w=majority Atlas Rapid Release (v5.1) MongoDB Shell (mongosh) MongoDB CRUD Operations TLS/SSL (Transport Encryption) Client-Side Field Level Encryption MongoDB grants access to data and commands through and provides built-in roles that provide the different levels of access commonly needed in a database system. A snippet of the code where the aggregate command exists.A snippet of the connection portion of your code (Please remove any credentials before posting it here).Below is the access which was available in MongoDB. We can give access and revoke the privileges of an existing user.

#MONGODB GRANT READWRITE DRIVER#
Which driver you are using to perform the command on We can modify the access of the existing or any user in MongoDB.Would you be able to provide the following information to help troubleshoot the error?:
