剛在redhat下安裝好mongodb但是卻完全無法使用指令

weixin_40030688 2019-03-19 10:15:53


刚安装好mongodb,主要是在晚上找的安装教程即设置,通过指令却无法进行操作,只能use user。晕~网上找的其他方法也不适用。
可能是我的用户没有授权?
但是我超级用户都还没创建怎么授权呢?


MongoDB shell version v3.6.0
connecting to: mongodb://127.0.0.1:27017
MongoDB server versio: 3.6.0



>use admin
switched to db admin

> db.createUser({
... user: "username",
... pwd: "password",
... roles: ["readWrite", "dbAdmin", "dbOwner"]
... });
2019-03-19T09:19:55.749+0800 E QUERY [thread1] Error: couldn't add user: not authorized on admin to execute command { createUser: "username", pwd: "xxx", roles: [ "readWrite", "dbAdmin", "dbOwner" ], digestPassword: false, writeConcern: { w: "majority", wtimeout: 600000.0 }, $db: "admin" } :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1437:15
@(shell):1:1


> show users
2019-03-19T09:14:15.358+0800 E QUERY [thread1] Error: not authorized on admin to execute command { usersInfo: 1.0, $db: "admin" } :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.getUsers@src/mongo/shell/db.js:1686:1
shellHelper.show@src/mongo/shell/utils.js:793:9
shellHelper@src/mongo/shell/utils.js:700:15
@(shellhelp2):1:1


>db.system.users.find()
Error: error: {
"ok" : 0,
"errmsg" : "not authorized on test to execute command { find: \"system.users\", filter: {}, $db: \"test\" }",
"code" : 13,
"codeName" : "Unauthorized"
}


> show dbs
2019-03-19T09:17:42.938+0800 E QUERY [thread1] Error: listDatabases failed:{
"ok" : 0,
"errmsg" : "not authorized on admin to execute command { listDatabases: 1.0, $db: \"admin\" }",
"code" : 13,
"codeName" : "Unauthorized"
} :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
Mongo.prototype.getDBs@src/mongo/shell/mongo.js:65:1
shellHelper.show@src/mongo/shell/utils.js:810:19
shellHelper@src/mongo/shell/utils.js:700:15
@(shellhelp2):1:1
...全文
87 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

1,747

社区成员

发帖
与我相关
我的任务
社区描述
MongoDB相关内容讨论区
社区管理员
  • MongoDB社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧