MongoDB查看所有⽤户账号信息在 MongoDB 中创建了很多帐号,怎么查看所有帐号信息?
1. 查看全局所有账户
2. 查看当前库下的账户
查看全局所有账户 :
> use admin
switched to db admin
> db.auth('admin','123456')
1
> db.system.users.find().pretty()
{
"_id" : "",
"user" : "root",
"db" : "admin",
"credentials" : {
"SCRAM-SHA-1" : {
"iterationCount" : 10000,
"salt" : "******************==",
"storedKey" : "*****************=",
"serverKey" : "**************="
}
},
"roles" : [
{
"role" : "read",
"db" : "admin"
},
{
"role" : "readWrite",
"db" : "admin"
},
{
"role" : "dbAdmin",
"db" : "admin"
},
{
"role" : "dbAdmin",
"db" : "devicedb"
}
]
}
{
"_id" : "st",
"user" : "test",
"db" : "test",
"credentials" : {
"SCRAM-SHA-1" : {
"iterationCount" : 10000,
"salt" : "******************==",
"storedKey" : "******************=",
"serverKey" : "******************="
}
},
"roles" : [
{
"role" : "read",
"db" : "test"
},
{
"role" : "readWrite",
"db" : "test"
},
{
"role" : "dbAdmin",
"db" : "test"
},
{
"role" : "userAdmin",
"db" : "test"
},
{
"role" : "dbOwner",
"db" : "test"
}
]
}
查看当前库下的账户 : > use admin
switched to db admin
> show users
{
"_id" : "",
"user" : "root",
"db" : "admin",
"roles" : [
{
"role" : "read",
"db" : "admin"
},
{
"role" : "readWrite", "db" : "admin"
},
{
"role" : "dbAdmin", "db" : "admin"
},
申请博客帐号{
"role" : "userAdmin", "db" : "admin"
},
{
"role" : "dbAdmin", "db" : "devicedb"
}
]
}
> use test
switched to db test
> show users
{
"_id" : "st",
"user" : "test",
"db" : "test",
"roles" : [
{
"role" : "read",
"db" : "test"
},
{
"role" : "readWrite", "db" : "test"
},
{
"role" : "dbAdmin", "db" : "test"
},
{
"role" : "userAdmin", "db" : "test"
},
{
"role" : "dbOwner", "db" : "test"
}
]
}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论