6

I know show users or db.getUsers() can show all users in current database in mongodb, but how to list all users in all databses for ease of management as an administrator?

asked Apr 16, 2016 at 9:26

3 Answers 3

5

You can find information about all users in all databases in system.users collection of admin database. See MongoDB documentation for system.users collection.

answered Apr 16, 2016 at 9:39
1

I know show users or db.getUsers() can show all users in current database in mongodb, but how to list all users in all databses for ease of management as an administrator?

I would like to say that, i am not discarding anything of @Saleem. To showing the all users in mongodb, suppose that if you have a GUI connection of mongodb with their client tool. you can also able to see all users in the mongodb database (System database as well as user databases). In my environment i have Robomongo mongodb third party client tool, through which i have connected mongodb with localhost and by default port of 27017.

You just connect the mongodb with Robomongo client tool. For showing all the users in mongodb the steps will be as follows:

Method 1:

  1. Expand your connection, Click on System folder. enter image description here
  2. After clicking on System folder, by default you shall get two databases(admin & local) like this way

enter image description here

Note: In my case i have already created the user databases like (MyFirstDB,Zubair,haidar,test).

  1. Expand the admin database, Go to collections folder then click on System folder. Within the System Folder there will be there metadata files like that

  2. system.indexes

  3. system.users
  4. system.version

enter image description here

  1. Right click on system.users, some of the options will appear in the new window. Among them choose the view Documents.

enter image description here

After that automatically the mongo shell will be open like as

enter image description here

As you can see the above mongo shell window under the key column . There is three users like

test.haidar (Here test is database and haidar is user)

test.vijay (Here test is database and vijay is user)

Haidar.skant (Here Haidar is database and skant is user)

you can see here the command like

db.system.users.find()

through which you shall find out the all users in the mongodb.

Method 2:

After connection the mongodb through Robomongo client tool.Expand the connection click on System folder then right click on admin database. enter image description here open the mongodb shell through the option like 'open shell'. The mongodb shell will be open . just type there the query like

db.system.users.find()

enter image description here

Execute the query through F5 or Execute button of the Robomongo client tool. And you shall get all users in the mongodb.

Note: In my conversion i have discuss about Robomongo client tool. It's third party freeware software tool, you can find out Here and Here. In my conversion i have used Robomongo 0.8.4.

Hope this will help out to you , for finding the all users in mongodb users.

answered Sep 11, 2017 at 8:50
1
  • 1
    How is that different from simply executing these commands on the shell (except displaying them on robomongo) Commented Apr 19, 2018 at 7:59
1

Try this:

use admin
db.system.users.find({}, { db: 1, user: 1})
answered Oct 10, 2019 at 11:07

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.