MongoDB installation and configuration under Windows

Source: Internet
Author: User
Tags mongodb mongodb client mongodb windows mongo shell

1. Download MongoDB Windows version, there are 32-bit and 64-bit version, download according to the system, download address: http://www.mongodb.org/downloads

2. Extract to D:/mongodb

3. Create a storage location for your 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 the success cannot start. The default folder path is c:/data/db. When using the system default folder path, the start service does not need to be described with the--dbpath parameter, but the folder is 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 18:49:34 MongoDB starting:pid=232 port=27017 dbpath=e:/mongodb/data
32-bit

* * Note:when using MongoDB bit, are limited to about 2 gigabytes of data

* * Http://blog.mongodb.org/post/137788967/32-bit-limitations

Sat 18:49:34 db version v1.6.5, pdfile version 4.5
Sat 18:49:34 git version:0eb017e9b2828155a67c5612183337b89e12e291
Sat 18:49:34 sys info:windows (5, 1, 2600, 2, ' Service Pack 3 ') Boost_li
B_version=1_35
Sat 18:49:34 [Initandlisten] waiting for connections on port 27017
Sat 18:49:34 [WEBSVR] Web admin interface listening on port 28017

Indicates successful startup, the last two lines of database port and Web port, the default is 27017 and 28017 respectively, open http://localhost:28017 in the browser, you can see some of its related information.

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

5. Then open a cmd input: D:/mongodb/bin>mongo, or double-click Mongo.exe, you can do mongodb client command operation, testing

>//the MONGO shell is a JavaScript shell connected to the DB
> 3+3
6
> DB
Test
>//The I-write to create the DB:
> Db.foo.insert ({a:1})
> Db.foo.find ()
{_id: ..., a:1}

6. So every time you start MongoDB is inconvenient, we can like the installation of MySQL as a Windows service, so much more convenient.
The way to install the MongoDB Windows service is to create the logs directory under the MongoDB installation directory, and then type in 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 '.

Represents a successful service creation.

The command line specifies the log file:/logs/mongodb.log, the log is output in an append way;

Data file directory:/data/db, and parameter--directoryperdb shows that each db will create a new directory;

Name of the Windows service: MongoDB;

All of the above three parameters can be determined according to their own circumstances.

Finally, the installation parameters:--install, and the relative is--remove

7, you can start and stop MongoDB under cmd with command net start MongoDB and net stop MongoDB, or you can see it in local Service

Manage the service through an 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.