On this page本页内容
MongoDB Atlas
Use this tutorial to install MongoDB 4.4 Community Edition on Windows using the default installation wizard.使用本教程可以使用默认安装向导在Windows上安装MongoDB 4.4 Community Edition。
This tutorial installs MongoDB 4.4 Community Edition.本教程安装MongoDB 4.4社区版。To install a different version of MongoDB Community, use the version drop-down menu in the upper-left corner of this page to select the documentation for that version.要安装不同版本的MongoDB社区,请使用此页面左上角的版本下拉菜单选择该版本的文档。
This tutorial installs MongoDB on Windows using the default installation wizard.本教程使用默认安装向导在Windows上安装MongoDB。Alternatively, you may chose to install MongoDB on Windows in an unattended fashion, using 或者,您可以选择在Windows上以无人参与的方式安装MongoDB,使用msiexec.exe
from the command line (cmd.exe
).msiexec.exe
文件从命令行(cmd.exe
)安装。This is useful for system administrators who wish to deploy MongoDB using automation.这对于希望使用自动化部署MongoDB的系统管理员非常有用。
➤ See Install MongoDB Community on Windows using msiexec.exe for instructions.请参阅使用msiexec.exe在Windows上安装MongoDB社区版的请示。
EOL Notice
MongoDB 4.4 Community Edition supports the following 64-bit versions of Windows on x86_64 architecture:MongoDB 4.4社区版支持x86_64体系结构上的以下64位版本的Windows:
MongoDB only supports the 64-bit versions of these platforms.MongoDB只支持这些平台的64位版本。
See Supported Platforms for more information.有关更多信息,请参阅支持的平台。
Before deploying MongoDB in a production environment, consider the Production Notes document which offers performance considerations and configuration recommendations for production MongoDB deployments.在生产环境中部署MongoDB之前,请考虑生产备忘录文档,该文档为生产MongoDB部署提供了性能注意事项和配置建议。
Follow these steps to install MongoDB Community Edition using the MongoDB Installer wizard.按照以下步骤使用MongoDB安装程序向导安装MongoDB社区版。The installation process installs both the MongoDB binaries as well as the default configuration file <install directory>\bin\mongod.cfg
.
Download the MongoDB Community 从以下链接下载MongoDB社区版的.msi
installer from the following link:.msi
安装程序:
➤ MongoDB Download CenterMongoDB下载中心
For example, from the Windows Explorer/File Explorer:例如,从Windows资源管理器/文件资源管理器:
.msi
file). By default, this is your Downloads
directory..msi
file.The wizard steps you through the installation of MongoDB and MongoDB Compass.向导将引导您完成MongoDB和MongoDB Compass的安装。
You can choose either the Complete (recommended for most users) or Custom setup type. The Complete setup option installs MongoDB and the MongoDB tools to the default location. The Custom setup option allows you to specify which executables are installed and where.
Starting in MongoDB 4.0, you can set up MongoDB as a Windows service during the install or just install the binaries.从MongoDB 4.0开始,您可以在安装过程中将MongoDB设置为Windows服务,也可以只安装二进制文件。
The following installs and configures MongoDB as a Windows service.
Starting in MongoDB 4.0, you can configure and start MongoDB as a Windows service during the install, and the MongoDB service is started upon successful installation.
This is a Windows user account that is built-in to Windows
or
.
) for the Account Domain and specify the Account Name and the Account Password for the user.MongoDB
. If you already have a service with the specified name, you must choose another name.--dbpath
. If the directory does not exist, the installer will create the directory and sets the directory access to the service user.--logpath
. If the directory does not exist, the installer will create the directory and sets the directory access to the service user.The following installs MongoDB only and does not configure MongoDB as a Windows service.
If you choose not to configure MongoDB as a Windows service, uncheck the Install MongoD as a Service.
Optional. To have the wizard install MongoDB Compass, select Install MongoDB Compass (Default).
The MongoDB service is started upon successful installation [1].
To begin using MongoDB, connect a mongo.exe
shell to the running MongoDB instance. Either:
C:\Program Files\MongoDB\Server\4.4\bin\
directory and double-click on mongo.exe
.For information on CRUD (Create,Read,Update,Delete) operations, see:
[1] | The MongoDB instance is configured using the configuration file <install directory>\bin\mongod.cfg . |
If you only installed the executables and did not install MongoDB as a Windows service, you must manually start the MongoDB instance.
See Run MongoDB Community Edition from the Command Interpreter for instructions to start a MongoDB instance.
Starting in version 4.0, you can install and configure MongoDB as a Windows Service during the install, and the MongoDB service is started upon successful installation. MongoDB is configured using the configuration file <install directory>\bin\mongod.cfg
.
To start/restart the MongoDB service, use the Services console:
To begin using MongoDB, connect a mongo.exe
shell to the running MongoDB instance. To connect, open a Command Interpreter with Administrative privileges and run:
For more information on connecting a mongo.exe
shell, such as to connect to a MongoDB instance running on a different host and/or port, see The mongo Shell. For information on CRUD (Create,Read,Update,Delete) operations, see:
To stop/pause the MongoDB service, use the Services console:
To remove the MongoDB service, first use the Services console to stop the service. Then open a Windows command prompt/interpreter (cmd.exe
) as an Administrator, and run the following command:
You can run MongoDB Community Edition from the Windows command prompt/interpreter (cmd.exe
) instead of as a service.
Open a Windows command prompt/interpreter (cmd.exe
) as an Administrator.
Important
You must open the command interpreter as an Administrator.
Create the data directory where MongoDB stores data. MongoDB’s default data directory path is the absolute path \data\db
on the drive from which you start MongoDB.
From the Command Interpreter, create the data directories:
To start MongoDB, run mongod.exe
.
The --dbpath
option points to your database directory.
If the MongoDB database server is running correctly, the Command Interpreter displays:
Important
Depending on the Windows Defender Firewall settings on your Windows host, Windows may display a Security Alert dialog box about blocking “some features” of C:\Program Files\MongoDB\Server\4.4\bin\mongod.exe
from communicating on networks. To remedy this issue:
To learn more about security and MongoDB, see the Security Documentation.
To connect a mongo.exe
shell to the MongoDB instance, open another Command Interpreter with Administrative privileges and run:
For more information on connecting a mongo.exe
shell, such as to connect to a MongoDB instance running on a different host and/or port, see The mongo Shell. For information on CRUD (Create,Read,Update,Delete) operations, see:
By default, MongoDB launches with bindIp
set to 127.0.0.1
, which binds to the localhost network interface. This means that the mongod.exe
can only accept connections from clients that are running on the same machine. Remote clients will not be able to connect to the mongod.exe
, and the mongod.exe
will not be able to initialize a replica set unless this value is set to a valid network interface.
This value can be configured either:
Warning
Before binding to a non-localhost (e.g. publicly accessible) IP address, ensure you have secured your cluster from unauthorized access. For a complete list of security recommendations, see Security Checklist. At minimum, consider enabling authentication and hardening network infrastructure.
For more information on configuring bindIp
, see IP Binding.
.msi
¶If you installed MongoDB with the Windows installer (.msi
), the .msi
automatically upgrades within its release series (e.g. 4.2.1 to 4.2.2).
Upgrading a full release series (e.g. 4.0 to 4.2) requires a new installation.
All command-line examples in this tutorial are provided as absolute paths to the MongoDB binaries. You can add C:\Program Files\MongoDB\Server\4.4\bin
to your System PATH
and then omit the full path to the MongoDB binaries.