为了账号安全,请及时绑定邮箱和手机立即绑定

创建用户失败

└─[$] <> ./bin/mongo 127.0.0.1:12345/test 

MongoDB shell version v4.0.0

connecting to: mongodb://127.0.0.1:12345/test

MongoDB server version: 4.0.0

> db.createUser({user:"imooc",pwd:"imooc",roles:[{role:"userAdmin",db:"admin"},{role:"read",db:"test"}]})

2018-07-09T14:35:16.752+0800 E QUERY    [js] Error: couldn't add user: not authorized on test to execute command { createUser: "imooc", pwd: "xxx", roles: [ { role: "userAdmin", db: "admin" }, { role: "read", db: "test" } ], digestPassword: true, writeConcern: { w: "majority", wtimeout: 600000.0 }, $db: "test" } :

_getErrorWithCode@src/mongo/shell/utils.js:25:13

DB.prototype.createUser@src/mongo/shell/db.js:1491:15

@(shell):1:1


正在回答

1 回答

这个你要先把auth权限关闭了,再重启,mongodb,再创建,成功了后,再开启auth权限,再用你创建的用户登录,就可以了。

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
mongoDB入门篇
  • 参与学习       95944    人
  • 解答问题       185    个

mongoDB入门视频教程,慕课网带你进入mongoDB神秘世界

进入课程

创建用户失败

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信