show dbs给出“未授权执行命令"错误 [英] show dbs gives "Not Authorized to execute command" error

查看:160
本文介绍了show dbs给出“未授权执行命令"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我花了一些时间试图找出问题所在,但由于找不到,我决定在这里询问.

I've spent some time trying to figure out what is wrong but as I could not find out, I decided to ask here.

我正在Windows 8上运行MongoDB(Windows 64位2008 R2 +)版本3.2.3,路径为:

I am running MongoDB(Windows 64-bit 2008 R2+) version 3.2.3 on Windows 8, the paths are :

C:\ MongoDB \ bin 进行安装

C:\ data \ db 用于数据文件夹

我已经安装了此视频

I've installed following this video and this tutorial from the official documentation.

第一个问题可能是客户端(mongo.exe)和服务器(mongod.exe)之间的连接,因为我根本不知道这是否是一个问题.

The first issue might be, as I don't really know if it is an issue at all, the connection between the client(mongo.exe) and the server(mongod.exe).

我通过命令行(具有管理员权限)启动了mongod.exe,一切正常,我得到了消息:

I lauched mongod.exe via the command line (with administrator rights), everything went fine, I got the message :

waiting for connections on port 27017

但是当我通过命令行的新实例启动mongo.exe时,服务器(mongod.exe)不会显示一条消息,指出存在新连接(在我观看的教程中就是这种情况)

but when I launch mongo.exe via a new instance of the command line, the server(mongod.exe) doesn't print a message saying there is a new connection (it was the case in the tutorials I watched)

另一方面,mongo.exe会打印

On the other side, mongo.exe prints

connecting to : test

我目前不知道一切是否正确,但我仍然尝试了一些基本命令,例如:

I don't know if everything is correct at this point but I still tried some basics commands like :

show dbs返回not authorized on admin to execute command

基本上,我尝试的所有命令都具有相同的错误消息,即使使用use 'dbName'

Basically, all the commands I tried had the same error message, even with "fresh" db I just created with use 'dbName'

一些在线回答说我必须创建一个具有适当角色的用户,我尝试了此用户. 仍然是相同的错误消息not authorized to execute command

Some answers online said I have to create a user with proper roles, I tried this one. Still the same error message not authorized to execute command

我的问题如下:

启动mongo.exe时mongod.exe不显示新连接是正常现象吗?如果正确,那我该怎么做,甚至使基本命令都能正常工作?

Is is normal that mongod.exe doesn't show a new connection when I launch mongo.exe ? If it is correct then what can I do to make even the basic commands work ?

其他信息:

我尝试使用Windows安装程序中的自定义模式"和完全模式"卸载/重新安装几次,但这总是导致相同的问题.

I tried to uninstall/re-install few times, with the "Custom mode" and the "Complete mode" in the Windows installer but it always lead to the same problem.

我也尝试按照官方文档创建MongoDB服务,但我不确定这是否是一个好主意. (我无法添加更多链接,但它位于我共享的第二个链接的一个部分中.

I also tried to create a MongoDB Service following the official documentation but I'm not really sure if it was a good idea. (I can't add more links but it is in a section in the second link I shared.

编辑部分:

我决定在另一台多年来没有接触过的计算机上尝试运行,该计算机运行在64位Windows 7上.

I decided to try it on another computer which I have not touched for years, running on Windows 7 64-bit.

我将MongoDB安装文件夹复制到了这台计算机的根目录,创建了\ data \ db文件夹并启动了mongod.exe.

I copied the MongoDB installation folder at the root of this computer, created \data\db folder and launched mongod.exe.

然后我启动了mongo.exe,这一次,mongod.exe打印了一条消息,说有一个新的打开的连接,该连接不在我的实际计算机上.我认为问题出在这里,因为我能够从官方文档开始基本教程并执行简单的命令,例如创建新的数据库,插入,查找,显示数据库等.在我的实际计算机上无法执行的所有操作

Then I launched mongo.exe and this time, mongod.exe printed a message saying there is a new open connection which it doesn't on my actual computer. I think the problem is here because I was able to start the basic tutorial from the official documentation and perform simple commands like create a new db, insert, find, show dbs, etc. Everything that I am not able to do on my actual computer.

所以我认为问题出在mongod.exe和mongo.exe之间的连接

So I think the problem is coming from the connection between mongod.exe and mongo.exe

您尝试过几次卸载后是否知道如何解决此问题?

Do you have any idea how I could solve this problem as I have tried uninstalling few times.

推荐答案

问题OP的副本:

解决方案

在上一次编辑的更新之后,我对客户端和服务器之间的连接进行了一些了解,发现即使mongod.exe没有运行,端口上仍有某物监听27017和netstat -a

After the update from the previous edit, I looked a bit about the connection between client and server and I found out that even when mongod.exe was not running, there was still something listening on port 27017 with netstat -a

所以我尝试使用

[dir]mongod.exe --port 2000

然后用

[dir]mongo.exe --port 2000

这一次,服务器打印了一条消息,指出存在新连接. 我打了几个命令,一切工作都很好,我从文档开始了基础教程,以检查现在是否还可以.

And this time, the server printed a message saying there is a new connection. I typed few commands and everything was working perfectly fine, I started the basic tutorial from the documentation to check if it was ok and for now it is.

这篇关于show dbs给出“未授权执行命令"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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