The installation of MongoDB under window

Source: Internet
Author: User
Tags install mongodb install mongodb windows mongodb version mongodb windows mongo shell

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 D:/mongodb

3. Create a storage location for the database files, such as d:/mongodb/data/db. 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, enter the D:/mongodb/bin directory, enter the following command to start the MongoDB service:

D:/mongodb/bin>mongod.exe--dbpath d:/mongodb/data/db

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:0eb017e9b2828155a67c5612183337b89e12e291
Sat Jan 18:49:34 sys info:windows (5, 1, 2600, 2, ' Service Pack 3 ') Boost_li
B_version=1_35
Sat Jan 18:49:34 [Initandlisten] waiting for connections on port 27017
Sat Jan 18:49:34 [websvr] Web admin interface listening on port 28017

Indicates a successful start, the last two lines of the database port and the Web port, the default is 27017 and 28017, in the browser open http://localhost:28017, you can see some information about it.

You can modify the database port by adding the parameter--port: D:/mongodb/bin>mongod.exe--port 10001--dbpath d:/mongodb/data/db

5. 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}

6. 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 the logs directory under the MongoDB installation directory and then enter it on the cmd command line
E:/mongodb/bin>mongod--logpath D:/mongodb/logs/mongodb.log--logappend

--dbpath d:/mongodb/data/db--directoryperdb--servicename MongoDB--install

Show:

All output Going To:d:/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.

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

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.