Install and configure MongoDB in Windows

Source: Internet
Author: User
Tags mongodb 32 bit mongodb client mongodb commands mongodb windows mongo shell

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

2. Extract the package to E:/MongoDB.

3. Create a storage location for database files, such as D:/MongoDB/data/DB. Before starting the MongoDB service, you must create a folder for storing database files. Otherwise, the command will not be created automatically and cannot be started successfully. The default folder path is C:/data/DB. When you use the System Default Folder path, you do not need to add the -- dbpath parameter to start the service, but you need to manually create the folder.

4. Open the CMD command line, enter the D:/MongoDB/bin directory, and enter the following command to start the MongoDB service:

D:/MongoDB/bin> mongod.exe -- dbpath D:/MongoDB/data/DB

Display:

Sat Jan 08 18:49:34 MongoDB starting: pid = 232 port = 27017 dbpath = E:/MongoDB/Data
32-bit

** Note: When Using MongoDB 32 bit, you are limited to about 2 gigabytes of data

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

Sat Jan 08 18:49:34 DB version v1.6.5, pdfile version 4.5
Sat Jan 08 18:49:34 git version: 0eb017e9b2828155a67c5612183337b89e12e291
Sat Jan 08 18:49:34 sys info: Windows (5, 1, 2600, 2, 'service pack 3') boost_li
B _version = Limit 35
Sat Jan 08 18:49:34 [initandlisten] waiting for connections on port 27017
Sat Jan 08 18:49:34 [websvr] Web Admin Interface listening on port 28017

 

Indicates that the startup is successful. The database port and Web port described in the last two lines are 27017 and 28017 by default. Open http: // localhost: 28017 in the browser, you can see some related information.

You can add the -- port parameter to modify the database port: D:/MongoDB/bin> mongod.exe -- port 10001 -- dbpath D:/MongoDB/data/DB

5. Open CMD and enter "D:/MongoDB/bin> retry". Then, double-click "cmd.exe" to run the commands on the MongoDB client.

 

> // The Mongo shell is a javascript shell connected to the DB
> 3 + 3
6
> DB
Test
> // The first write will create the DB:
> DB. Foo. insert ({A: 1 })
> DB. Foo. Find ()
{_ ID:..., A: 1}

 

6. In this way, it is inconvenient to start MongoDB every time. We can use it as a Windows service just like the installed MySQL, which is much more convenient.
Install the MongoDB Windows service by creating the logs directory under the MongoDB installation directory, and then entering
E:/MongoDB/bin> mongod -- logpath D:/MongoDB/logs/MongoDB. log -- logappend

-- Dbpath D:/MongoDB/data/DB -- directoryperdb -- servicename MongoDB -- install

Display:

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 "'.

Indicates that the service is successfully created.

The command line specifies the log file/logs/MongoDB. log, which is output in append mode;

Data File directory:/data/dB, and the parameter -- directoryperdb indicates that each database creates a directory;

Windows Service name: MongoDB;

The above three parameters can be set based on your own situation.

The last installation parameter is -- install, which is opposite to -- remove.

7. In the future, run the Net start MongoDB and net stop MongoDB commands in cmd to start and stop MongoDB. You can also see it in the local service.

Manage the service through the interface.

8. Set Environment Variables
Mongodb_home = D: \ MongoDB
Same time % mongodb_home % \ bin put in Path


This article from: http://blog.csdn.net/liuzhoulong/article/details/6124566

Thank you, bro.

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.