mongosh

https://www.mongodb.com/docs/manual/tutorial/configure-scram-client-authentication/#std-label-create-user-admin

use admin
switched to db admin

 

db.createUser(
  {
    user: "myUserAdmin",
    pwd: passwordPrompt(), // or cleartext password
    roles: [
      { role: "userAdminAnyDatabase", db: "admin" },
      { role: "readWriteAnyDatabase", db: "admin" }
    ]
  }
)

显示所有数据库

 show dbs

切换到admin数据库之后,

 show users 可以列出所有用户

 

posted @ 2024-01-10 14:27  ChuckLu  阅读(4)  评论(0编辑  收藏  举报