1. 在 选择下载所需的版本。
2. 执行 msi 安装包,可通过 Custom 选项,选择安装目录。
3. 创建数据目录。MongoDB 需要一个存储数据的目录,如果不指定, Windows 环境默认使用 c:\data\db。
D:\>mkdir data\db
4. 运行服务。
D:\Program Files\MongoDB\Server\3.2\bin>mongod.exe --dbpath D:\data\db
5. 运行MongoDB Shell。
MongoDB 启动选项
以下的选项都可以从 获得更详细的参考。
--help, -h
This returns the information on the options and use of mongod.--version
This returns the mongod release number.--config <filename>
This specifies the configuration file to be used by mongod.--port <port>
This specifies the TCP listening port on which MongoDB listens. (the default is 27017)--bind_ip <ip address>
This specifies the IP address that mongod binds to in order to listen for connections from applications (the default is All interfaces.).--logpath <path>
This sends all diagnostic logging information to a log file instead of to a standard output or to the host's syslog system.--logappend
This appends new entries to the end of the log file rather than overwriting the content of the log when the mongod instance restarts.--httpinterface
This enables the HTTP interface. Enabling the interface can increase network exposure.--fork
This enables a daemon mode that runs the mongod process in the background. By default, mongod does not run as a daemon.--auth
This enables authorization to control the user's access to database resources and operations. When authorization is enabled, MongoDB requires all clients to authenticate themselves first in order to determine the access for the client.--noauth
This disables authentication. It is currently the default and exists for future compatibility and clarity--rest
This enables the simple REST API. Enabling the REST API enables the HTTP interface, even if the HTTP interface option is disabled, and as a result can increase network exposure.--profile <level>
This changes the level of database profiling (0 Off, which means no profiling; 1 On, which only includes slow operations; and 2 On, which includes all the operations.)--shutdown
This safely terminates the mongod process. It is available only on Linux systems.--dbpath <path>
This is the directory where the mongod instance stores its data. The default is /data/db on Linux and OS X and C:\data\db on Windows.--storageEngine string
This specifies the storage engine for the mongod database. The valid options include mmapv1 and wiredTiger. The default is mmapv1.--directoryperdb
This stores each database's files in its own folder in the data directory. When applied to an existing system, the --directoryperdb option alters the storage pattern of the data directory.