1) Download MongoDB
Http://downloads.mongodb.org/win32/mongodb-win32-i386-2.4.4.zip
2) set the MongoDB Directory
Decompress it to d:/and rename it to mongodb. The path is d:/mongodb.
3) set the data file path
Create a data folder in d: Disk and create a new db folder in the data folder. Path: d:/data/db
4) start the MongoDB service
Enter the cmd prompt console,
The code is as follows: |
Copy code |
D:/mongodb/bin/mongod.exe -- dbpath = d:/data/db Mon Apr 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 08:50:54 Mon Apr 16 08:50:54 [initandlisten] MongoDB starting: pid = 5084 port = 27017 dbpat H = d:/data/db 32-bit host = PC-201012302214 Mon Apr 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 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 = limit 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 |
Default connection port of the MongoDB server: 27017
5) use MongoDB as a Windows service for random startup
Create the D:/mongodb/logs/mongodb. log file to store the MongoDB log file, and then install the system service:
The code is as follows: |
Copy code |
D:/mongodb/bin/mongod -- dbpath = d:/data/db -- logpath = d:/mongodb/logs/mongodb. log -- install 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 Mongo DB service has been started successfully.
D:> Note: If you need to uninstall the service, run the command SC delete MongoDB.
6) client connection verification
Open a new CMD input: d:/mongodb/bin/mongo. If the following prompt appears, you can start your MongoDB journey:
The code is as follows: |
Copy code |
D:/mongodb/bin/mongo MongoDB shell version: 2.4.4 Connecting to: test
|
> 7) view MongoDB logs
View the D:/mongodb/logs/mongodb. log file to view the running status of MongoDB or troubleshoot it.