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?
3 Answers 3
You can find information about all users in all databases in system.users
collection of admin
database. See MongoDB documentation for system.users collection.
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:
- Expand your connection, Click on
System
folder. enter image description here - After clicking on System folder, by default you shall get
two databases
(admin
&local
) like this way
Note: In my case i have already created the user databases like (MyFirstDB,Zubair,haidar,test).
Expand the
admin
database, Go tocollections
folder then click onSystem
folder. Within the System Folder there will be theremetadata
files like thatsystem.indexes
- system.users
- system.version
- Right click on
system.users
, some of the options will appear in the new window. Among them choose theview Documents
.
After that automatically the mongo shell
will be open like as
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()
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.
-
1How is that different from simply executing these commands on the shell (except displaying them on robomongo)Mehdi LAMRANI– Mehdi LAMRANI2018年04月19日 07:59:06 +00:00Commented Apr 19, 2018 at 7:59
Try this:
use admin
db.system.users.find({}, { db: 1, user: 1})