如何在windows上安装MongoDB(译)
?
原文出自:http://www.mkyong.com/mongodb/how-to-install-mongodb-on-windows/
?
How To Install MongoDB On Windows
?
In this tutorial, we will show you how to install?MongoDB?on Windows.
译:在本教程中,我们将告诉你如何在Windows上安装MongoDB。
?
- MongoDB 2.2.3
- Windows 7
Note
The MongoDB does not require installation, just download and extracts the zip file, configure the data directory and start it with command “mongod
“.
译:注,MongoDB不需要安装,只要下载并提取ZIP文件,配置数据目录,使用"mongod"命令启动。
1. Download MongoDB
Download MongoDB from official?MongoDB website. Choose Windows 32 bits or 64 bits. Unzip, extracts to your prefer location, for example :?d:\mongodb\
.
译:从官方网站MongoDB website下载MongoDB。选择Windows 32位或64位。解压,提取到你喜欢的位置,例如:D:\mongodb\。
2. Review MongoDB folder
In MongoDB, it contains only 10+ executable files (exe) in the bin folder. This is true, and that are the required files to MongoDB, it’s really hard to believe for a developer like me who come from a relation database background.
译:在MongoDB中,它仅包含10 +可执行文件(EXE),都在Bin文件夹中。对于一个来自关系型数据库背景的人来说,这真是一件很难的事情。
?
Figure : Files under $MongoDB/bin folder
图:$MongoDB/bin 文件夹下的所有文件。
Note
It’s recommended to add?$MongoDB/bin
?to Windows environment variable, so that you can access the MongoDB’s commands in command prompt easily.?
译:注,建议增加 $MongoDB / bin 的Windows环境变量,这样你可以在命令提示符下很容易的使用MongoDB命令。
3. Configuration File
Create a MongoDB config file, it’s just a text file, for example :?d:\mongodb\mongo.config
译:创建MongoDB配置文件,他可以只是一个文本文件,例如:D:\ mongodb \ mongo.config
?
d:\mongodb\mongo.config
?
##store data here dbpath=D:\mongodb\data ##all output go here logpath=D:\mongodb\log\mongo.log ##log read and write operations diaglog=3
?
?
Note
MongoDB need a folder (data directory) to store its data. By default, it will store in “C:\data\db
“, create this folder manually. MongoDB won’t create it for you. You can also specify an alternate data directory with?--dbpath
?option.
译:MongoDB需要一个文件夹(数据目录)来存储它的数据。默认情况下,它将存储在“C:\data\db”,你需要手动创建该文件夹。MongoDB不会为你创造它。你也可以指定一个数据目录——dbpath 选项。
4. Run MongoDB server
Use?mongod.exe --config d:\mongodb\mongo.config
?to start MongoDB server.
译:使用mongod.exe --config d:\mongodb\mongo.config命令来启动MongoDB服务器。
?
?
d:\mongodb\bin>mongod --config D:\mongodb\mongo.config all output going to: D:\mongodb\log\mongo.log
?
5. Connect to MongoDB
Uses?mongo.exe
?to connect to the started MongoDB server.
译:使用mongo.exe命令连接到已经启动的MongoDB服务器。
?
?
d:\mongodb\bin>mongo MongoDB shell version: 2.2.3 connecting to: test > //mongodb shell
?
6. MongoDB as Windows Service
Add MongoDB as Windows Service, so that MongoDB will start automatically following each system restart.
译:添加MongoDB作为Windows服务,使MongoDB会在每次系统重新启动时自动启动。
?
Install as Windows Service with?--install
.
?
d:\mongodb\bin> mongod --config D:\mongodb\mongo.config --install
?
?
A Windows service named “MongoDB” is created.
译:一个windows服务已经创建,名为"MongoDB"。
?
To start MongoDB Service
?
net start MongoDB
To stop MongoDB Service?
?
?
net stop MongoDB
?
To remove MongoDB Service
?
d:\mongodb\bin>mongod --remove
?
7. FAQs
1. Install MongoDB as Windows service on Windows 8, but hit “Access is denied.” error message :
译:在windows8中为MongoDB安装windows服务,但是遇到"访问被拒绝"错误消息。
?
C:\Users\mkyong2002>mongod --config D:\mongodb\mongo.config --install Tue Jul 16 21:05:55.154 diagLogging level=3 Tue Jul 16 21:05:55.155 diagLogging using file D:\mongodb\data/diaglog.51e54533 Tue Jul 16 21:05:55.155 Trying to install Windows service ‘MongoDB‘ Tue Jul 16 21:05:55.155 Error connecting to the Service Control Manager: Access is denied. (5)
?
?
To fix it, run the Command Prompt with?Administrative Privileges?– right click on the command prompt icon, select run as administrator.
译:修复,右键运行命令提示符图标,管理权限,以管理员身份运行。
?
References
?
?
?
?
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。