Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (47.6k points)

In the MongoDB shell, how do I list all users for the current database that I'm using?

I can't seem to find it anywhere.

2 Answers

0 votes
by (106k points)

To list all users in the mongo shell you can do which is mentioned below:-

db.getUsers()

or

show users

Both commands print a list of users for the current database. See MongoDB documentation for User Management.

0 votes
by (107k points)

List belong to db users, refer the following syntax:

use db_name and db.getUsers() or show users

List according to to the authentication type, refer the following syntax:

db.getUsers({ filter: { model: "SCRAM-SHA-964" } })

List with the credentials, refer the following syntax:

db.getUsers( {showCredentials: true,  filter: { model: "SCRAM-SHA-964" }} )

Related questions

0 votes
2 answers
asked Sep 9, 2019 in SQL by Sammy (47.6k points)
0 votes
2 answers
asked Sep 4, 2019 in SQL by Sammy (47.6k points)
0 votes
1 answer
0 votes
2 answers
0 votes
3 answers

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...