1. Install and run mongodb under WIN7

1)、下载MongoDB
http://downloads.mongodb.org/win32/mongodb-win32-i386-2.4.5.zip

Download the Windows 32-bit version and unzip it. The program files are in the bin directory, and the other two directories are the header files and library files for C++ calls. The bin directory contains the following programs:
1. mongo.exe, a command-line client tool.
2. mongod.exe, the database service program.
3. mongodump.exe, the database backup program.
4. mongoexport.exe, data export tool.
5. mongofiles.exe, GridFS tool.
6. mongoimport.exe, data import tool.
7. mongorestore.exe, database recovery tool.
8. mongos.exe, seems to be a performance testing tool.

2) , set the MongoDB directory

Unzip it to d:\ , then rename it to mongodb, the path is d:\mongodb

3) , set the data file path

Create a data folder on the d: drive, and create a new db folder in the data folder, the path is d:\mongodb\data\db

 

4) , start the MongoDB service

Enter the cmd  prompt console,
D:\mongodb\bin\mongod.exe --dbpath=d:\mongodb\data\db

 

 

 

 

Mon Apr 16 08:50:54
Mon Apr 16 08:50:54 warning: 32-bit servers don't have journaling enabled by def
ault. Please use --journal if you want durability.
Mon Apr 16 08:50:54
Mon Apr 16 08:50:54 [initandlisten] MongoDB starting : pid=5084port=27017 dbpat
h=d:\mongodb\data\db 32-bit host=PC-201012302214
Mon Apr 16 08:50:54 [initandlisten]
Mon Apr 16 08:50:54 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are
limited to about 2 gigabytes of data
Mon Apr 16 08:50:54 [initandlisten] ** see http://blog.mongodb.org/post/13
7788967/32-bit-limitations
Mon Apr 16 08:50:54 [initandlisten] **       with --journal, the limit is lower
Mon Apr 16 08:50:54 [initandlisten]
Mon Apr 16 08:50:54 [initandlisten] db version v2.0.4, pdfile version 4.5
Mon Apr 16 08:50:54 [initandlisten] git version: 329f3c47fe8136c03392c8f0e548506
cb21f8ebf
Mon Apr 16 08:50:54 [initandlisten] build info: windows sys.getwindowsversion(ma
jor=6, minor=0, build=6002, platform=2, service_pack='Service Pack 2') BOOST_LIB
_VERSION=1_42
Mon Apr 16 08:50:54 [initandlisten] options: { dbpath: "d:\data\db" }
Mon Apr 16 08:50:54 [websvr] admin web console waiting for connections on port 2
8017
Mon Apr 16 08:50:54 [initandlisten] waiting for connections on port 27017

The default connection port of the MongoDB server: 27017

5) , start MongoDB randomly as a Windows service

Create D:\mongodb\logs\mongodb.log file to store MongoDB log files, and then install system services:
D:\mongodb\bin\mongod  --dbpath =d:\ mongodb\ data\db  --logpath = d :\mongodb\logs \mongodb.log --install   

(If you are prompted: Error connecting to the Service Control Manager, you should run cmd as an administrator 

Find the command handler C:\Windows\System32\cmd.exe
Right click: run as administrator

 

all output going to: d:\mongodb\logs\mongodb.log  
 Creating service MongoDB.  
 Service creation successful.  
 Service can be started from the command line via 'net start "MongoDB"'.
 D:\>net start mongodb  
 The MongoDB service has been started successfully.   
 D:>

 

Note: If you need to uninstall the service, execute the command: sc delete MongoDB

 

 

6) , client connection verification

新打开一个CMD输入:d:\mongodb\bin\mongo,如果出现下面提示,那么您就可以开始MongoDB之旅了:

d:\mongodb\bin\mongo  
MongoDB shell version: 2.0.4  
connecting to: test  

 

 

7)、查看MongoDB日志

查看D:\mongodb\logs\mongodb.log文件,即可对MongoDB的运行情况进行查看或排错。

 

 http://localhost:27017/可以看到如下提示:
You are trying to access MongoDB on the native driver port. For http diagnostic access, add 1000 to the port number
如此,MongoDB数据库服务已经成功启动了。

http://localhost:28017/管理

 

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326950861&siteId=291194637