Docs Menu
Docs Home
/ /
MongoDB Command Line Interface
/ / /

mongocli atlas dbuser delete

On this page

  • Syntax
  • Options
  • Output
  • Example

The dbuser delete command deletes the specified MongoDB database user on the specified Atlas cluster. The command prompts you to confirm the operation when you run the command without the --force option.

You can also delete a MongoDB database user through the Atlas UI or API.

mongocli atlas dbuser delete <username>
[ --force ]
[ --authDB ]
[ --output|-o <output-format> ]
[ --profile|-P <profile-name> ]
[ --projectId <project-ID> ]

Note

Use -h or --help to view the command-line help for this command.

Option
Type
Description
Required?
--force
Flag that indicates that the user can be deleted without requiring confirmation.
no
--authDB
string
Name of the authentication database for this user. Defaults to admin.
no
--output, -o
string

Command output format. Valid values are:

  • json for output in JSON format

  • go-template for custom output using the Go template

  • go-template-file for custom output specified using Go template file

If omitted, the command returns output in the default format.

no
--profile, -P
string
Name of the profile where the public and private keys for the project are saved. If omitted, uses the default profile. To learn more about creating a profile, see Configure the MongoDB CLI.
no
--projectId
string

Unique identifier of the project. If omitted, uses the project ID in the profile or environment variable.

no
<username>
string
Username for authenticating the user to MongoDB.
yes

The command prints a confirmation message similar to the following to the terminal if it succeeds. If the command prints an error, see Troubleshooting for recommended solutions.

DB user '<username>' deleted

where <username> is the username of the MongoDB user who was deleted.

The following examples use the mongocli atlas dbuser delete command to delete a user named janeDoe.

The following mongocli atlas dbuser delete command deletes a user named janeDoe after prompting for a confirmation. It uses the default profile to access the Atlas cluster.

mongocli atlas dbuser delete janeDoe
Are you sure you want to delete: janeDoe Yes

The command prints the following to the terminal:

DB user 'janeDoe' deleted

The following mongocli atlas dbuser delete command deletes a user named janeDoe without requiring confirmation. It uses the default profile to access the Atlas cluster.

mongocli atlas dbuser delete janeDoe --force

The command prints the following to the terminal:

DB user 'janeDoe' deleted

Back

Modify a Database User