Docs Home / mongosh

Install 安装mongosh

msiexec.exe

This section describes how to install mongosh on Windows through the MSI installer.本节介绍如何通过MSI安装程序在Windows上安装mongosh

If you already have mongosh installed and want to upgrade to the latest version, see Upgrade mongosh.如果您已经安装了mongosh并希望升级到最新版本,请参阅升级mongosh

Prerequisites先决条件

To use the MongoDB Shell, you must have a MongoDB deployment to connect to.要使用MongoDB Shell,您必须有一个MongoDB部署才能连接。

Supported MongoDB Versions支持的MongoDB版本

You can use the MongoDB Shell to connect to MongoDB version 7.0 or greater.您可以使用MongoDB Shell连接到MongoDB 7.0或更高版本。

Supported Operating Systems支持的操作系统

You can install MongoDB Shell on these Windows operating systems:您可以在以下Windows操作系统上安装MongoDB Shell:

  • Microsoft Windows Server 2016+
  • Microsoft Windows 10+

Procedure过程

Note

On Windows, mongosh preferences and configuration options are stored in the %APPDATA%/mongodb/mongosh directory.在Windows上,mongosh首选项和配置选项存储在%APPDATA%/mongodb/mongosh目录中。

1

Open the MongoDB Shell download page.打开MongoDB Shell下载页面。

Open the MongoDB Download Center.打开MongoDB下载中心

2

In the Platform dropdown, select Windows 64-bit (10+) (MSI)在“平台”下拉列表中,选择“Windows 64位(10+)”(MSI)

3

Click Download.单击“下载”。

4

Double-click the installer file.双击安装程序文件。

5

Follow the prompts to install mongosh.按照提示安装mongosh

Zip File

This section describes how to install mongosh on Windows through the .zip archive.本节介绍如何通过.zip存档在Windows上安装mongosh

If you already have mongosh installed and want to upgrade to the latest version, see Upgrade mongosh.如果您已经安装了mongosh并希望升级到最新版本,请参阅升级mongosh

Prerequisites先决条件

To use the MongoDB Shell, you must have a MongoDB deployment to connect to.要使用MongoDB Shell,您必须有一个MongoDB部署才能连接。

Supported MongoDB Versions支持的MongoDB版本

You can use the MongoDB Shell to connect to MongoDB version 7.0 or greater.您可以使用MongoDB Shell连接到MongoDB 7.0或更高版本。

Supported Operating Systems支持的操作系统

You can install MongoDB Shell on these Windows operating systems:您可以在以下Windows操作系统上安装MongoDB Shell:

  • Microsoft Windows Server 2016+
  • Microsoft Windows 10+

Procedure过程

Note

On Windows, mongosh preferences and configuration options are stored in the %APPDATA%/mongodb/mongosh directory.在Windows上,mongosh首选项和配置选项存储在%APPDATA%/mongodb/mongosh目录中。

1

Open the MongoDB Shell download page.打开MongoDB Shell下载页面。

Open the MongoDB Download Center.打开MongoDB下载中心

2

Download the mongosh installation archive for your operating system.下载适用于您操作系统的mongosh安装存档。

Download mongosh from the MongoDB Download Center.MongoDB下载中心下载mongosh

3

Extract the files from the downloaded archive.从下载的存档中提取文件。

Open a cmd terminal and run the following command from the directory that has the mongosh .zip archive:打开cmd终端,从包含mongosh .zip存档的目录中运行以下命令:

tar -xf mongosh-2.5.10-win32-x64.zip

The extracted archive has a bin folder that contains two files, mongosh.exe and mongosh_crypt_v1.dll.提取的存档有一个bin文件夹,其中包含两个文件mongosh.exemongosh_crypt_v1.dll

4

Add the mongosh binary to your PATH environment variable.mongosh二进制文件添加到PATH环境变量中。

Ensure that the extracted MongoDB Shell binary is in the desired location in your filesystem, then add that location to your PATH environment variable.确保提取的MongoDB Shell二进制文件位于文件系统中的所需位置,然后将该位置添加到PATH环境变量中。

To add the MongoDB Shell binary's location to your PATH environment variable:要将MongoDB Shell二进制文件的位置添加到PATH环境变量中:

  1. Open the Control Panel.打开“控制面板”。
  2. In the System and Security category, click System.在“系统和安全”类别中,单击“系统”。

  3. Click Advanced system settings. The System Properties modal displays.单击“高级系统设置”。“系统属性”模式显示。
  4. Click Environment Variables.单击“环境变量”。
  5. In the System variables section, select Path and click Edit. The Edit environment variable modal displays.在“系统变量”部分,选择“路径”并单击“编辑”。将显示“编辑环境变量”模式。

  6. Click New and add the filepath to your mongosh binary.单击“新建”并将文件路径添加到mongosh二进制文件中。
  7. Click OK to confirm your changes. On each other modal, click OK to confirm your changes.单击“确定”确认更改。在其他模式中,单击“确定”以确认更改。

To confirm that your PATH environment variable is correctly configured to find mongosh, open a command prompt and enter the mongosh --help command. 要确认PATH环境变量已正确配置为查找mongosh,请打开命令提示符并输入mongosh --help命令。If your PATH is configured correctly, a list of valid commands displays.如果PATH配置正确,将显示有效命令列表。

Next Steps后续步骤

After you successfully install mongosh, learn how to connect to your MongoDB deployment.成功安装mongosh后,学习如何连接到MongoDB部署

MongoDB provides a programmatically accessible list of mongosh downloads that can be accessed through your application.MongoDB提供了一个可编程访问的mongosh下载列表,可以通过应用程序访问。