1

На Fedora23 я установил MongoDB, используя dnf .

sudo dnf install -y mongod
sudo systemctl restart mongod

Однако это не работает для show dbs

$ mongo
MongoDB shell version: 3.0.9
connecting to: test
> show dbs
2016-03-08T14:45:58.188+0530 E QUERY    Error: listDatabases failed:{
    "ok" : 0,
    "errmsg" : "not authorized on admin to execute command { listDatabases: 1.0 }",
    "code" : 13
}
    at Error (<anonymous>)
    at Mongo.getDBs (src/mongo/shell/mongo.js:47:15)
    at shellHelper.show (src/mongo/shell/utils.js:630:33)
    at shellHelper (src/mongo/shell/utils.js:524:36)
    at (shellhelp2):1:1 at src/mongo/shell/mongo.js:47
> 

Это тоже не работает:

> db.createUser({user: "admin", pwd: "password", roles: [{role: "root", db: "admin"}]})
2016-03-08T14:48:34.595+0530 E QUERY    Error: couldn't add user: not authorized on test to execute command { createUser: "admin", pwd: "xxx", roles: [ { role: "root", db: "admin" } ], digestPassword: false, writeConcern: { w: "majority", wtimeout: 30000.0 } }
    at Error (<anonymous>)
    at DB.createUser (src/mongo/shell/db.js:1101:11)
    at (shell):1:4 at src/mongo/shell/db.js:1101
> 

Ссылка: https://stackoverflow.com/questions/23943651/mongodb-admin-user-not-authorized

Даже с sudo mongo я вижу те же ошибки.

Как это исправить?

0