0

use admin
switched to db admin
> show dbs
2020-06-19T16:33:34.220+0800 listDatabases failed:{
“ok” : 0,
“errmsg” : “not authorized on admin to execute command { listDatabases: 1.0 }”,
“code” : 13
} at src/mongo/shell/mongo.js:47

请问各位大佬2个问题:
一、刚手动安装了 MongoDB 2.6.4 版本,是tar.gz解压的;启动后,就登录进来,然后其他的什么都没操作,使用了use admin命令和show dbs命令,就报错了。。。

二、也是什么都没操作,添加用户也报错,如下。。。

use admin
switched to db admin
> db.createUser({user:”admin”,pwd:”2%GCZ@K-(=27″,roles:[{role:”root”,db:”admin”}]})
2020-06-19T16:20:04.575+0800 Error: couldn’t add user: not authorized on admin to execute command { createUser: “admin”, pwd: “xxx”, roles: [ { role: “root”, db: “admin” } ], digestPassword: false, writeConcern: { w: “majority”, wtimeout: 30000.0 } } at src/mongo/shell/db.js:1004

 

 

Answered question