1. Download MongoDB version of Windows, there are 32-bit and 64-bit version, according to the system download,: Http://www.mongodb.org/downloads
2. Unzip to the amount E:/mongodb
3. Create a storage location for the database files, such as D:/mongodb/data. You must create a storage folder for the database files before you start the MongoDB service, otherwise the command will not be created automatically and cannot start successfully. The default folder path is c:/data/db. When you use the System default folder path, the startup service does not need to add--dbpath parameter descriptions, but folders are also created manually
4. Open the cmd command line, first enter e: Click OK, then enter CD MongoDB, click OK, then enter the CD bin, which I tested successfully. Enter the D:/mongodb/bin directory and enter the following command to start the MongoDB service:
E:/mongodb/bin>mongod.exe--dbpath E:/mongodb/data
Show:
Sat Jan 18:49:34 MongoDB starting:pid=232 port=27017 dbpath=e:/mongodb/data 32-bit
* * Note:when using MongoDB + bit, you is limited to about 2 gigabytes of data
* * See http://blog.mongodb.org/post/137788967/32-bit-limitations
Sat Jan 18:49:34 db version v1.6.5, pdfile version 4.5 Sat Jan 18:49:34 git version:0eb017e9b2828155a67c5612183337b 89e12e291 Sat Jan 18:49:34 Sys info:windows (5, 1, 2600, 2, ' Service Pack 3 ') boost_li b_version=1_35 Sat Jan 08 18:49 : [Initandlisten] waiting for connections on port 27017 Sat Jan 18:49:34 [websvr] Web Admin interface listening on PO RT 28017
Indicates a successful start, the last two lines of the database port and the Web port, the default is 27017, open http://localhost:27017 in the browser, you can see some information about it.
You can modify the database port by adding the parameter--port: E:/mongodb/bin>mongod.exe--port 10001--dbpath e:/mongodb/data
5. So it's inconvenient to start mongodb every time, we can use it as a Windows service like MySQL, so it's much easier. The way to install MongoDB Windows Services is to create a log directory under the MongoDB installation directory
, and then enter E:/mongodb/bin>mongod--logpath e:/mongodb/log/mongodb.log on the cmd command line--logappend
--dbpath e:/mongodb/data/db--directoryperdb--servicename MongoDB--install
Show:
All output going to:e:/mongodb/logs/mongodb.log Creating service MongoDB. Service creation successful. Service can is started from the command line via ' net start ' MongoDB '.
Indicates that the service was created successfully.
Note: After testing may not show, do not error, directly start the next step is good.
The command line specifies the log file:/logs/mongodb.log, the log is output in an append manner;
Data file directory:/data/db, and the parameter--directoryperdb indicates that each DB will create a new directory;
Name of the Windows service: MongoDB;
The above three parameters can be determined according to their own circumstances.
Finally, the installation parameters:--install, the opposite is--remove
6. Open a cmd input: D:/mongodb/bin>mongo, or double-click Mongo.exe, you can do the client command operation of MongoDB, under test
>//The MONGO shell is a JavaScript shell connected to the DB
> 3+3 6
> DB
Test > //The first write would create the DB:
> Db.foo.insert ({a:1})
> Db.foo.find () {_id: ..., a:1}
7, you can start and stop MongoDB under cmd with command net start MongoDB and net stop MongoDB, also can see in the Local service
Manage the service through the interface.
The installation and use of MongoDB under Win7