db.logout()バージョン 5.0 から非推奨。
Attempting to use the
db.logout()method will write an error message to the log once per logout attempt.このメソッドは、将来のリリースで削除される予定です。
現在の認証セッションを終了します。 この関数は、現在のセッションが認証されていない場合、効果はありません。
注意
If you're not logged in and using authentication,
db.logout()has no effect.Because MongoDB allows users defined in one database to have privileges on another database, you must call
db.logout()while using the same database context that you authenticated to.If you authenticated to a database such as
usersor$external, you must issuedb.logout()against this database in order to successfully log out.例
Use the
use <database-name>helper inmongosh, or the followingdb.getSiblingDB()method in an interactivemongoshsession or inmongoshshell scripts to change thedbobject:db = db.getSiblingDB('<database-name>') When you have set the database context and
dbobject, you can use thedb.logout()to log out of database as in the following operation:db.logout() db.logout()function provides a wrapper around the database commandlogout.
互換性
このメソッドは、次の環境でホストされている配置で使用できます。
- MongoDB Atlas はクラウドでの MongoDB 配置のための完全管理サービスです
注意
このコマンドは、すべての MongoDB Atlas クラスターでサポートされています。すべてのコマンドに対する Atlas のサポートについては、「サポートされていないコマンド」を参照してください。
MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン
MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン