logoutcommand terminates the current authenticated session:
If you’re not logged in and using authentication,
logouthas no effect.
Because MongoDB allows users defined in one database to have privileges on another database, you must call
logoutwhile using the same database context that you authenticated to.
If you authenticated to a database such as
$external, you must issue
logoutagainst this database in order to successfully log out.
When you have set the database context and
dbobject, you can use the
logoutto log out of database as in the following operation: