如何使用命令行知道安装了哪个 MongoDB 版本?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41431530/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 20:52:32  来源:igfitidea点击:

How do I know which MongoDB version is installed by using the Command Line?

mongodbcmdversion

提问by Codesingh

Without changing directory to \MongoDB\bin\, when I call:

无需将目录更改为 \MongoDB\bin\,当我调用时:

mongod -v

I get:

我得到:

'mongod' is not recognized as an internal or external command, operable
program or batch file.

When I call the same command from \bin\ it launches the server just like I'm calling:

当我从 \bin\ 调用相同的命令时,它会像我调用一样启动服务器:

mongod

It is the same case with 'mongo' and 'mongos'.

'mongo' 和 'mongos' 也是如此。

I added the \bin\ path to the environment variables thinking it will help but it didn't.

我将 \bin\ 路径添加到环境变量中,认为它会有所帮助,但它没有。

To clarify with an example, to get the version of Ruby, I can call:

举例说明,要获取 Ruby 的版本,我可以调用:

ruby -v

Why can't I do the same with MongoDB?

为什么我不能用 MongoDB 做同样的事情?

回答by Codesingh

First add location of MongoDB's bin folder to PATH env variable. This is required because it is the place where mongod.exe is stored. For example, if MongoDB 4.0 is in your Program Files, add "C:\Program Files\MongoDB\Server\4.0\bin" to PATH for all system users. Then try using :

首先将 MongoDB 的 bin 文件夹的位置添加到 PATH 环境变量。这是必需的,因为它是存储 mongod.exe 的地方。例如,如果 MongoDB 4.0 在您的 Program Files 中,请将“C:\Program Files\MongoDB\Server\4.0\bin”添加到所有系统用户的 PATH 中。然后尝试使用:

mongod --version