Zum Inhalt springen

Create and manage users

Diese Seite ist noch nicht in deiner Sprache verfügbar. Englische Seite aufrufen

To get a list of all users for a MongoDB Flex instance:

FlagDescription
instance-idInstance ID of the instance you want to query
Terminal window
stackit mongodbflex user list --instance-id <instance-id>

You get the following output:

ID │ USERNAME
─────────────────────────────────────┼──────────
703e5cce-463c-43f9-975c-36be5a8e2511 │ n44pk1sj
107d5d48-1540-4509-bc07-2a0ad0945c5b │ zvwn577e

To create a user for a MongoDB Flex instance:

FlagDescriptionDefaultOptional
instance-idInstance ID of the instance you want to query
databaseDatabase name for which the permissions should be set
roleRole of the user (read, readWrite)readx
usernameUsername of the new userx
Terminal window
stackit mongodbflex user create --instance-id <instance-id> --database <database>

You get the following output:

Created user for instance "mongodb-87ffl67rc1dd". User ID: a2a0e3d9-2281-4368-9337-a6903b613592
Username: zvwn577e
Password: S7ihJf9cbFdfzd7m
Roles: [read]
Database: books
Host: s-9092270d-c65a-45db-82bb-f259f3941f22-0.mongodb.eu01.onstackit.cloud
Port: 27017
URI: mongodb://zvwn577e:S7ihJf9cbFdfzd7m@s-9092270d-c65a-45db-82bb-f259f3941f22-0.mongodb.eu01.onstackit.cloud:27017/books?authSource=books&tls=true&authMechanism=SCRAM-SHA-256

To get details of a user for a MongoDB Flex instance:

FlagDescriptionDefaultOptional
instance-idInstance ID of the instance you want to query
user-idThe ID of the user (not its username)
Terminal window
stackit mongodbflex user describe <user-id> --instance-id <instance-id>

You get the following output:

ID │ a2a0e3d9-2281-4368-9337-a6903b613592
──────────┼───────────────────────────────────────────────────────────────────────
USERNAME │ z8n9ybsi
──────────┼───────────────────────────────────────────────────────────────────────
ROLES │ [read]
──────────┼───────────────────────────────────────────────────────────────────────
DATABASE │ books
──────────┼───────────────────────────────────────────────────────────────────────
HOST │ s-9092270d-c65a-45db-82bb-f259f3941f22-0.mongodb.eu01.onstackit.cloud
──────────┼───────────────────────────────────────────────────────────────────────
PORT │ 27017

To delete a user for a MongoDB Flex instance:

FlagDescriptionDefaultOptional
instance-idInstance ID of the instance you want to query
user-idThe ID of the user (not its username)
Terminal window
stackit mongodbflex user delete <user-id> --instance-id <instance-id>

After confirmation you get the following output:

Deleted user "z8n9ybsi" of instance "mongodb-87ffl67rc1dd"