In the recent work need to use MongoDB, here to do some simple records, blog post content can be found in the official MongoDB reference manual, here is just a few summary and explanation.
Installation Environment:
Os:windows 7, 32-bit
mongodb:3.0.6, currently the latest version
(1) Download the package that matches the system, you choose according to the system situation
as follows: Https://www.mongodb.org/downloads
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/DF/wKiom1Xu5KOCstMkAAJvXIDDAZ8571.jpg "title=" Download Page " alt= "Wkiom1xu5kocstmkaajvxiddaz8571.jpg"/>
(2) Unzip the download package and rename it to Mongdb (rename is for easy configuration), I am here to decompress: D:\Study\mongodb
(3) Create a new data folder in MongoDB, and then under the data file, create a new DB and log folder to form the following directory structure
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/E0/wKiom1Xu53_gLnFGAAEUwkNFT48983.jpg "title=" directory Structure " alt= "Wkiom1xu53_glnfgaaeuwknft48983.jpg"/>
Like the name of a folder, DB is the directory where MongoDB stores data, and log is the directory of MongoDB, because MongoDB does not automatically create folders, so we need to create them in advance
(4) Running MongoDB
Method one: From the command line, go to the MongoDB bin directory, execute the following command:
Mongod--logpath D:\Study\mongodb\data\log\mongod.log--logappend--dbpath=d:\study\mongodb\data\db
The meanings of several parameters of the Mongod command are as follows:
LogPath: log file, note is the file, not the log directory ;
Logappend: Additional form of logging
DBPath: Data Store file path, note is path
Method Two: Write the configuration file, write the command parameters to the configuration file, create a new mongodb.config in Mongdb
SystemLog:destination:file Path:d:\study\mongodb\data\log\mongod.log Logappend:truestorage:dbpath:d:\stu Dy\mongodb\data\db
For configuration items in the configuration file, you can refer to the section in the official reference manual for the contents of the config file options.
This method works the same way as the above method with the following command:
Mongod--config D:\Study\mongodb\mongodb.config
If the startup succeeds, you can open the log file to see the following, 27017 is the default port number for MongoDB:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/DD/wKioL1Xu7GCDfmqKAAPQfWLMYGA363.jpg "title=" Start Log " alt= "Wkiol1xu7gcdfmqkaapqfwlmyga363.jpg"/>
You can enter: http://localhost:27017/in the browser address bar to see the following interface indicating that MongoDB started successfully.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/DD/wKioL1Xu7a-iX9E4AABVm2gsTO4348.jpg "title=" Browser access. png "alt=" wkiol1xu7a-ix9e4aabvm2gsto4348.jpg "/>
The way to run MongoDB above is to use only a few parameters, more parameters can be used: Mongod--help command to view.
(5) Connect to MongoDB
go to the bin directory of MongoDB, run the Monge command, or double-click monge.exe
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/DD/wKioL1Xu7zmDJnXhAALNR1rcGiI385.jpg "title=" Connect to Mongodb.png "alt=" Wkiol1xu7zmdjnxhaalnr1rcgii385.jpg "/>
MongoDB By default is connected to the test database, you can use show DBS to view all the databases in MongoDB, you may feel strange, not connected to the test database, why the show DBS command did not see the test database, I think so, because there is no data in the test database, so MongoDB also did not create the corresponding file, when you create a corresponding collection, MongoDB create a file, again using show DBS will be able to see the test database.
(6) Creating service services
Every time it starts up like the above is troublesome, if you want MongoDB to boot, you need to create service services, if you have to view the official website configuration profile Description, in fact, about the service definition.
As an administrator, execute the following command to register the service service, if not an administrator, will cause the registration service to fail, in fact, and the above configuration file started MongoDB very similar, just one more parameter--install:
Mongod--config D:\Study\mongodb\mongodb.config--install
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/E0/wKiom1Xu8T7wf12gAAKTJzIdDKs075.jpg "title=" Register the Windows service. png "alt=" wkiom1xu8t7wf12gaaktjziddks075.jpg "/>
Start Service command: net start mongodb stop service command: net stop MongoDB
(7) Removal of service services
If you do not want to mongdb service, you can use the following command to remove
Mongod--remove
This article is from "Ace's Dream" blog, please be sure to keep this source http://acesdream.blog.51cto.com/10029622/1692929
Install MongoDB under Win 7