MongoDB installation and configuration under Windows 7

Source: Internet
Author: User
Tags mongodb client mongodb version mongodb windows net command mongo shell

The first step to download MongoDB:

Download MongoDB version of Windows, with 32-bit and 64-bit versions, downloaded according to the operating system:http://www.mongodb.org/downloads

Unzip to the specified directory, such as E:/mongodb.

The second stepis to create the DBPath:

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.

Create a storage location for the database file, such as e:/mongodb/data/db (that is, create the appropriate folder under E:/mongodb).

The default folder path is c:/data/db. When using the system default folder path, the startup service does not need to add--dbpath parameter descriptions, but folders are also created manually.

The third step is to open the cmd command line :

Open the cmd command line with your system administrator and go to the E:/mongodb/bin directory:

>CD E:/mongodb/bin

Enter the following command to start the MongoDB service:

E:/mongodb/bin>mongod.exe--dbpath e:/mongodb/data/db

The following information is displayed to start successfully:

MongoDB starting:pid=232 port=27017 dbpath=e:/mongodb/data 64-bit host=xxx-pc

Targetminos:windows 7/windows Server R2

DB version v2.6.3, pdfile version 4.5

Git version:0eb017e9b2828155a67c5612183337b89e12e291

Waiting for connections on port 27017

Modify Port:

You can modify the database port by adding the parameter--port:

E:/mongodb/bin>mongod.exe--port 10001--dbpath e:/mongodb/data/db

Fourth Step Client command operation :

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

The test is as follows:

>//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}
Fifth Step add into Windows service :

As above, each start mongodb very inconvenient, we can like the installation of MySQL, as the Windows services, so much more convenient.

To install the MongoDB Windows service:

1. Create the logs directory under the MongoDB installation directory

2. Then enter on the cmd command line

E:/mongodb/bin>mongod--logpath E:/mongodb/logs/mongodb.log--logappend

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

Displays the following information, indicating success (or not displaying the information, viewing whether the log was generated, and seeing if the Windows service was added successfully):

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

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

The sixth step starts/stops MongoDB with the net command under CMD:

Use the command net start MongoDB and net stop MongoDB to start and stop MongoDB.

You can see in the Local service:

You can also manage the start/stop of the service through the interface.

MongoDB installation and configuration under Windows 7

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.