Orange Receptacle
Orange Receptacle

Reputation: 1183

MongoDB: All commands spit out "not authorized on admin to execute command"

I spun up a mongoDB droplet so that I could have a database connected to my little game. However, complications after complications have arisen. I am connecting to the droplet through PuTTY and was previously able to invoke "mongo" then type "show dbs" to see all the current databases.

I had been altering the /etc/mongod.conf file to allow remote connecting, and since then - any command that I invoke spits back an error message:

Just through a simple show dbs - I get this.

> show dbs
2016-12-28T00:12:26.655+0000 E QUERY    [thread1] Error: listDatabases failed:{
        "ok" : 0,
        "errmsg" : "not authorized on admin to execute command { listDatabases: 1.0 }",
        "code" : 13
} :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
Mongo.prototype.getDBs@src/mongo/shell/mongo.js:62:1
shellHelper.show@src/mongo/shell/utils.js:761:19
shellHelper@src/mongo/shell/utils.js:651:15
@(shellhelp2):1:1

I'm so confused as to why this is and I've been scouring the internet to find anything that could possibly resolve this.

Upvotes: 2

Views: 17206

Answers (3)

abobakr
abobakr

Reputation: 1

Quick workaround will be to check by disable authorization .

sed -i -e 's/authorization: enabled/authorization: disabled/' /etc/mongod.conf
systemctl restart mongod.service

Upvotes: 0

Davi Soares
Davi Soares

Reputation: 25

sudo nano /etc/mongod.conf Disable (# auth = true)

Upvotes: 0

Robert Walters
Robert Walters

Reputation: 1397

The problem is that you are connected to a MongoDB instance that has authorization enabled and when you connected to MongoDB via the shell you didn't specify any credentials. The MongoDB shell will allow you to connect in this case but any command you type will error out.

Upvotes: 4

Related Questions