mongodb3.0没有admin数据库了,怎么添加超级管理员

如题所述

参照官方的说明,使用db.createUser()方法添加。
db.createUser(user, writeConcern)
Creates a new user for the database where the method runs. db.createUser() returns a duplicate user error if the user already exists on the database.
--------------------------
use products
db.createUser( { "user" : "accountAdmin01",
"pwd": "cleartext password",
"customData" : { employeeId: 12345 },
"roles" : [ { role: "clusterAdmin", db: "admin" },
{ role: "readAnyDatabase", db: "admin" },
"readWrite"
] },
{ w: "majority" , wtimeout: 5000 } )
温馨提示:答案为网友推荐,仅供参考