Logging in as a new user does not automatically logout any previous users in the current session (use db.logout()
for this).
There are some use cases where you may need to combine user permissions (for example, reading from one database and writing to another) where a single user in your environment does not have all required privileges. This is a somewhat legacy carryover from older versions of MongoDB (2.2 and earlier) that had more simplistic per-database authentication without custom roles and privileges.
To see current authenticated users in the current mongo
shell session, use db.runCommand({connectionStatus : 1})
.
version()
anddb.version()
? Logging in as a new user does not automatically logout any previous users in the current session (usedb.logout()
for this). There are use cases where you may need to combine user permissions (for example, reading from one database and writing to another) where a single user in your environment does not have all required privileges. To see current auth'd users in themongo
shell:db.runCommand({connectionStatus : 1}).