Database Manual / Reference / mongosh Methods

User Management Methods

Note

For details on a specific method, including syntax and examples, click on the link to the method's reference page.

NameDescription

db.auth()

Authenticates a user to a database.

db.changeUserPassword()

Changes an existing user's password.

db.createUser()

Creates a new user.

db.dropUser()

Removes a single user.

db.dropAllUsers()

Deletes all users associated with a database.

db.getUser()

Returns information about the specified user.

db.getUsers()

Returns information about all users associated with a database.

db.grantRolesToUser()

Grants a role and its privileges to a user.

db.removeUser()

Deprecated. Removes a user from a database.

db.revokeRolesFromUser()

Removes a role from a user.

db.updateUser()

Updates user data.

passwordPrompt()

Prompts for the password as an alternative to specifying passwords directly in various mongosh user authentication/management methods.