MongoDB 查看所有用户账号信息
在 MongoDB 中创建了很多帐号,怎么查看所有帐号信息?1. 查看全局所有账户2. 查看当前库下的账户查看全局所有账户 :
> use adminswitched to db admin> db.auth('admin','123456')1> db.system.users.find().pretty(){"_id" : "admin.root","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" : "test.test","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 adminswitched to db admin> show users{"_id" : "admin.root","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 testswitched to db test> show users{"_id" : "test.test","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"}]}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。