对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

db.logout()(mongosh方法)

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 users or $external, you must issue db.logout() against this database in order to successfully log out.

例子

Use the use <database-name> helper in mongosh, or the following db.getSiblingDB() method in an interactive mongosh session or in mongosh shell scripts to change the db object:

db = db.getSiblingDB('<database-name>')

When you have set the database context and db object, you can use the db.logout() to log out of database as in the following operation:

db.logout()

db.logout() function provides a wrapper around the database command logout.

此方法可用于以下环境中托管的部署:

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud

注意

This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.

给本页内容打分

在此页面上