Mongodb未经管理员授权执行listDatabases命令 [英] Mongodb not authorized on admin to execute listDatabases command

查看:201
本文介绍了Mongodb未经管理员授权执行listDatabases命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

删除mongodb用户后,如果不重新启动mongo,将无法重新连接 身份验证

After droping mongodb user ,not able to reconnect mongo again without authentication

我创建了超级用户 tomuser

我在ubuntu终端中的命令序列

1. use admin

2. db.dropUser('tomuser') true exit

2.db.dropUser('tomuser') true exit

3. sudo /etc/init.d/mongod stop

4. sudo /etc/init.d/mongod start

5. restart pc

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

我遇到了错误! not authorized on admin to execute command

所以,删除用户..后无法连接mongodb.

有什么遗漏的东西吗??

is there any thing missing ...?

推荐答案

第一种方法

1st way

我认为db.system.users中应该有另一个用户.如果是这样,请使用保存的用户登录.

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

> db.system.users.find({})
  null

我们可以通过mongo --port 27017访问mongodb.

第二种方法-常见的问题原因

2nd way - Usual cause of problem

使用 sudo mongod --port 27017

代替 sudo mongod --auth --port 27017 --dbpath /var/lib/mongodb

注释:仅当用户名& 密码 身份验证已设置

note : --auth is only required when username & password authentication is setup

这篇关于Mongodb未经管理员授权执行listDatabases命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆