永发信息网

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

答案:1  悬赏:20  手机版
解决时间 2021-11-08 11:05
  • 提问者网友:疯子也有疯子的情调
  • 2021-11-07 18:36
mongodb3.0没有admin数据库了,怎么添加超级管理员
最佳答案
  • 五星知识达人网友:玩家
  • 2021-11-07 19:26
mongodb3.0添加超级管理员使用使用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 } )
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯