剛安裝好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
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/68498.html
標籤:MongoDB
上一篇:kettle 周期執行job 報寫入日志錯誤,停止執行,重新啟動又正常
下一篇:有誰能給一份報表需求書模板嗎?
