简体   繁体   中英

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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM