TypeError: db.addUser is not a function : @(shell):1:1 ——mongoDB创建新用户名密码的方法

不多说,旧版本使用

db.addUser("root","root")

新版本使用这句会出现这个错误提示

TypeError: db.addUser is not a function : @(shell):1:1

新版本用的是

 db.createUser(
  {
    user: "test",
    pwd: "test",
    roles: [ { role: "userAdmin", db: "test" } ]
  }
)
原文地址:https://www.cnblogs.com/pyj63/p/8127950.html