Mongodb 未授权管理员执行 listDatabases 命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34787610/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Mongodb not authorized on admin to execute listDatabases command
提问by Mr punch
After droping mongodb user ,not able to reconnect mongo again without authentication
删除 mongodb 用户后,未经身份验证无法重新连接 mongo
i had created superusertomuser
我创建了超级用户tomuser
my command sequence in ubuntu terminal
我在 ubuntu 终端中的命令序列
1.use admin
1.use admin
2.db.dropUser('tomuser')
true
exit
2.db.dropUser('tomuser')
true
exit
3.sudo /etc/init.d/mongod stop
3.sudo /etc/init.d/mongod stop
4.sudo /etc/init.d/mongod start
4.sudo /etc/init.d/mongod start
5.restart pc
5.restart pc
6.mongo --port 27017
6.mongo --port 27017
7.> show dbs
2016-01-14T16:03:55.420+0530 listDatabases failed:{
"ok" : 0,
"errmsg" : "not authorized on admin to execute command { listDatabases: 1.0 }",
"code" : 13
} at src/mongo/shell/mongo.js:47
7.> show dbs
2016-01-14T16:03:55.420+0530 listDatabases failed:{
"ok" : 0,
"errmsg" : "not authorized on admin to execute command { listDatabases: 1.0 }",
"code" : 13
} at src/mongo/shell/mongo.js:47
I am getting above error!! not authorized on admin to execute command
我遇到了以上错误!! not authorized on admin to execute command
so ,not able to connect mongodb after dropping user ..?
所以,在删除用户后无法连接 mongodb ..?
is there any thing missing ...?
有什么遗漏吗......?
回答by zangw
1st way
第一种方式
I think there should be another user in the db.system.users
. If so, please use the saved user to log in.
我认为db.system.users
. 如果是这样,请使用保存的用户登录。
If there is NO users in the db.system.users
如果没有用户 db.system.users
> db.system.users.find({})
null
we can access mongodb
through mongo --port 27017
.
我们可以mongodb
通过mongo --port 27017
.
2nd way - Usual cause of problem
第二种方式 - 问题的常见原因
usesudo mongod --port 27017
用sudo mongod --port 27017
instead ofsudo mongod --auth --port 27017 --dbpath /var/lib/mongodb
代替sudo mongod --auth --port 27017 --dbpath /var/lib/mongodb
note : --authis only required when username& passwordauthenticationis setup
注意:-- auth仅在设置用户名和密码身份验证时才需要