1

On Fedora23 I installed MongoDB using dnf.

sudo dnf install -y mongod
sudo systemctl restart mongod

However it doesn't work for 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
> 

This doesn't work either:

> 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
> 

Ref: https://stackoverflow.com/questions/23943651/mongodb-admin-user-not-authorized

Even with sudo mongo I am seeing same errors.

How do I fix this?

2
  • do you have any selinux denials in audit?
    – Jakuje
    Mar 8, 2016 at 12:04
  • 1
    nevermind, I resolved this issue. It is nothing to do with selinux. The problem was that I was running a docker contain with ports mapped to same port that mongodb server would use. The error was hidden deep inside the logfile.
    – tuxdna
    Mar 8, 2016 at 15:41

0

You must log in to answer this question.

Browse other questions tagged .