Install MongoDB on Windows (Windows下安装MongoDB)
Install MongoDB on Windows
Overview
Use this tutorial to install MongoDB on a Windows systems.
PLATFORM SUPPORT
Starting in version 2.2, MongoDB does not support Windows XP. Please use a more recent version of Windows to use more recent releases of MongoDB.
IMPORTANT
If you are running any edition of Windows Server 2008 R2 or Windows 7, please install a hotfix to resolve an issue with memory mapped files on Windows.
Install MongoDB
Determine which MongoDB build you need.
There are three builds of MongoDB for Windows:
MongoDB for Windows Server 2008 R2 edition (i.e. 2008R2) runs only on Windows Server 2008 R2, Windows 7 64-bit, and newer versions of Windows. This build takes advantage of recent enhancements to the Windows Platform and cannot operate on older versions of Windows.
MongoDB for Windows 64-bit runs on any 64-bit version of Windows newer than Windows XP, including Windows Server 2008 R2 and Windows 7 64-bit.
MongoDB for Windows 32-bit runs on any 32-bit version of Windows newer than Windows XP. 32-bit versions of MongoDB are only intended for older systems and for use in testing and development systems. 32-bit versions of MongoDB only support databases smaller than 2GB.
To find which version of Windows you are running, enter the following command in the Command Prompt:
wmic os get osarchitecture
Download MongoDB for Windows.
Download the latest production release of MongoDB from the MongoDB downloads page. Ensure you download the correct version of MongoDB for your Windows system. The 64-bit versions of MongoDB does not work with 32-bit Windows.
Install the downloaded file.
In Windows Explorer, locate the downloaded MongoDB msi file, which typically is located in the defaultDownloads folder. Double-click the msi file. A set of screens will appear to guide you through the installation process.
Move the MongoDB folder to another location (optional).
To move the MongoDB folder, you must issue the move command as an Administrator. For example, to move the folder to C:\mongodb:
Select Start Menu > All Programs > Accessories.
Right-click Command Prompt and select Run as Administrator from the popup menu.
Issue the following commands:
cd \
move C:\mongodb-win32-* C:\mongodb
MongoDB is self-contained and does not have any other system dependencies. You can run MongoDB from any folder you choose. You may install MongoDB in any folder (e.g. D:\test\mongodb)
Run MongoDB
WARNING
Do not make mongod.exe visible on public networks without running in “Secure Mode” with the authsetting. MongoDB is designed to be run in trusted environments, and the database does not enable “Secure Mode” by default.
Set up the MongoDB environment.
MongoDB requires a data directory to store all data. MongoDB’s default data directory path is\data\db. Create this folder using the following commands from a Command Prompt:
md \data\db
You can specify an alternate path for data files using the --dbpath option to mongod.exe, for example:
C:\mongodb\bin\mongod.exe --dbpath d:\test\mongodb\data
If your path includes spaces, enclose the entire path in double quotes, for example:
C:\mongodb\bin\mongod.exe --dbpath "d:\test\mongo db data"
Start MongoDB.
To start MongoDB, run mongod.exe. For example, from the Command Prompt:
C:\Program Files\MongoDB\bin\mongod.exe
This starts the main MongoDB database process. The waiting for connections message in the console output indicates that the mongod.exe process is running successfully.
Depending on the security level of your system, Windows may pop up a Security Alert dialog box about blocking “some features” of C:\Program Files\MongoDB\bin\mongod.exe from communicating on networks. All users should select Private Networks, such as my home or work network and click Allow access. For additional information on security and MongoDB, please see the Security Documentation.
Connect to MongoDB.
To connect to MongoDB through the mongo.exe shell, open another Command Prompt. When connecting, specify the data directory if necessary. This step provides several example connection commands.
If your MongoDB installation uses the default data directory, connect without specifying the data directory:
C:\mongodb\bin\mongo.exe
If you installation uses a different data directory, specify the directory when connecting, as in this example:
C:\mongodb\bin\mongod.exe --dbpath d:\test\mongodb\data
If your path includes spaces, enclose the entire path in double quotes. For example:
C:\mongodb\bin\mongod.exe --dbpath "d:\test\mongo db data"
If you want to develop applications using .NET, see the documentation of C# and MongoDB for more information.
Begin using MongoDB.
To begin using MongoDB, see Getting Started with MongoDB. Also consider the Production Notesdocument before deploying MongoDB in a production environment.
Configure a Windows Service for MongoDB
NOTE
There is a known issue for MongoDB 2.6.0, SERVER-13515, which prevents the use of the instructions in this section. For MongoDB 2.6.0, use Manually Create a Windows Service for MongoDB to create a Windows Service for MongoDB instead.
Configure directories and files.
Create a configuration file and a directory path for MongoDB log output (logpath):
Create a specific directory for MongoDB log files:
md "C:\Program Files\MongoDB\log"
In the Command Prompt, create a configuration file for the logpath option for MongoDB:
echo logpath="C:\Program Files\MongoDB\log\mongo.log" > "C:\Program Files\MongoDB\mongod.cfg"
Run the MongoDB service.
Run all of the following commands in Command Prompt with “Administrative Privileges:”
Install the MongoDB service. For --install to succeed, you must specify the logpath run-time option.
"C:\Program Files\MongoDB\bin\mongod.exe" --config "C:\Program Files\MongoDB\mongod.cfg" --install
Modify the path to the mongod.cfg file as needed.
To use an alternate dbpath, specify the path in the configuration file (e.g. C:\ProgramFiles\MongoDB\mongod.cfg) or on the command line with the --dbpath option.
If the dbpath directory does not exist, mongod.exe will not start. The default value for dbpath is\data\db.
If needed, you can install services for multiple instances of mongod.exe or mongos.exe. Install each service with a unique --serviceName and --serviceDisplayName. Use multiple instances only when sufficient system resources exist and your system design requires it.
Stop or remove the MongoDB service as needed.
To stop the MongoDB service use the following command:
net stop MongoDB
To remove the MongoDB service use the following command:
"C:\Program Files\MongoDB\bin\mongod.exe" --remove
Manually Create a Windows Service for MongoDB
The following procedure assumes you have installed MongoDB using the MSI installer, with the default pathC:\Program Files\MongoDB 2.6 Standard.
If you have installed in an alternative directory, you will need to adjust the paths as appropriate.
Open an Administrator command prompt.
Windows 7 / Vista / Server 2008 (and R2)
Press Win + R, then type cmd, then press Ctrl + Shift + Enter.
Windows 8
Press Win + X, then press A.
Execute the remaining steps from the Administrator command prompt.
Create directories.
Create directories for your database and log files:
mkdir c:\data\db
mkdir c:\data\log
Create a configuration file.
Create a configuration file. This file can include any of the configuration options for mongod, but mustinclude a valid setting for logpath:
The following creates a configuration file, specifying both the logpath and the dbpath settings in the configuration file:
echo logpath=c:\data\log\mongod.log> "C:\Program Files\MongoDB 2.6 Standard\mongod.cfg"
echo dbpath=c:\data\db>> "C:\Program Files\MongoDB 2.6 Standard\mongod.cfg"
Create the MongoDB service.
Create the MongoDB service.
sc.exe create MongoDB binPath= "\"C:\Program Files\MongoDB 2.6 Standard\bin\mongod.exe\" --service --config=\"C:\Program Files\MongoDB 2.6 Standard\mongod.cfg\"" DisplayName= "MongoDB 2.6 Standard" start= "auto"
sc.exe requires a space between “=” and the configuration values (eg “binPath= ”), and a “” to escape double quotes.
If successfully created, the following log message will display:
[SC] CreateService SUCCESS
Start the MongoDB service.
net start MongoDB
Stop or remove the MongoDB service as needed.
To stop the MongoDB service, use the following command:
net stop MongoDB
To remove the MongoDB service, first stop the service and then run the following command:
sc.exe delete MongoDB
Install MongoDB on Windows (Windows下安装MongoDB)的更多相关文章
- Windows 环境下安装MongoDB
mongoDB下载地址 https://www.mongodb.org/ 在mongoDB官网下载windows版本的mongoDB后解压出来(本文以解压到D盘为例) 在解压出来的MongoDB文件夹 ...
- Windows 7下安装MongoDB
1.下载mongodb-win32-x86_64-2008plus-2.6.7-signed.msi(如今最新版本号已经到了3.0) 2.如果为64位操作系统则双击 mongodb-win32-x86 ...
- windows XAMPP下安装mongoDB
1.下载 下载地址:http://www.mongodb.org/downloads 2.安装 进入cmd第一步:D:\xampp\mongodb\bin\mongod.exe --dbpath=D: ...
- MongoDB基础之一:Conetos下安装MongoDB
1.下载自己需要的版本,我这用的是mongodb-linux-x86_64-2.4.9.tgz #cd /usr/local/src # wget http://fastdl.mongodb.org/ ...
- Windows 下安装 MongoDB
Windows 下安装 MongoDB 的步骤:1.官网www.mongodb.com下载安装包或zip包2.解压下载的文件到文件夹 D:\mongo .3.使用管理员权限打开CMD,导航到目录 D: ...
- windows下安装MongoDB扩展和配置
windows下安装MongoDB扩展和配置 1.下载mongoDB扩展,根据当前php版本进行下载 地址如下:http://pecl.php.net/package/mongo 我本地php版本是 ...
- 在Windows下安装MongoDB
概述 读者可以通过本文来学习在Windows操作系统上安装MongoDB. 从2.2版本开始,Mongo DB不在支持Windows XP.请使用最近的windows来安装最近发布的MongoDB.本 ...
- 【MongoDb--初入江湖】windows下安装MongoDb
一.windows下安装MongoDb http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/
- windows下安装MongoDB进度条不动
windows 下安装MongoDB, 在 Installing MongoDB Compass...(this may take a few minutes) 一步,会停留很长时间,点击取消可能也会 ...
- (一)windows下安装MongoDB解压版
windows下安装MongoDB解压版 我安装的是(mongodb-win32-x86_64-2008plus-ssl-4.0.8.zip)版本 亲测可以使用. 连接: Windows下MongoD ...
随机推荐
- linux启动黑屏或无法进入会话管理器
原因是因为更新软件时删除了/etc中的xserver配置文件,进入livecd将相关文件拷贝即可
- CoreAnimation实现一个折线表
将折现表封装到一个view里,暴露给使用者的只有一个传入数据的方法. // // ChartLine.h // BoxingChampion //功能:根据传入的数组,绘制折线图 注意 其frame的 ...
- C#的输入输出流
一 .NET Framework 类库的System.IO 命名空间 System.IO 命名空间包含允许读写文件和数据流的类型以及提供基本文件和目录支持的类型. 二 C#文件读写之Fi ...
- 手机定位原理 - GPS/GLONASS/北斗 + WIFI + 基站
卫星定位系统 - GPS/GLONASS/北斗: 关于GPS.GLONASS.北斗.伽利略系统的科普请自行谷歌. GPS是使用最广泛的全球定位网络,几乎是所有智能手机的标配.进几年,俄罗斯的GLONA ...
- wamp不能使用phpmyadmin,提示“You don't have permission to access /phpmyadmin/ on this server.” 转载
换了win8之后wamp明显不怎么好用了,显示80端口被system占用,后是masql出现了403错误,多番百度谷歌找到了解决方案,这里与大家分享 当你安装完成wamp后,打开localhost或i ...
- http请求的组成部分
报文流 1.HTTP 报文是在HTTP 应用程序之间发送的数据块.这些数据块以一些文本形式的元信息(meta-information)开头,这些信息描述了报文的内容及含义,后面跟着可选的数据部分.这些 ...
- Jquery效果之固定不动的块
好多页面都有用到这种效果,大概就是不论页面上下如何滚动,固定不动的元素不随页面滚动,代码如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 ...
- 大数据技术人年度盛事! BDTC 2016将于12月8-10日在京举行
2016年12月8日-10日,由中国计算机学会(CCF)主办,CCF大数据专家委员会承办,中国科学院计算技术研究所和CSDN共同协办的2016中国大数据技术大会(Big Data Technology ...
- 从文章"避免复制与粘贴"到文章"Extract Method"的反思(3)
在牛人的博客中提到了..如果你的代码可以copy-past的时候,那么久证明你的代码出现了重复.而这种重复仅仅是虚假的代码行的增加而不是像其他的代码复用那样降级成本. copy-pase代码意味着你违 ...
- 2016多校联合训练contest4 1012Bubble Sort
Bubble Sort Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Tota ...