Install MongoDB on Windows

Source: Internet
Author: User
Tags install mongodb

Install MongoDB on Windows

MongoDB is widely used in a variety of large portal websites and professional websites with its features such as simple operations, free of charge, open source code, and ready-to-download. This greatly reduces operating costs. This article describes the installation steps and procedures on the Widows platform for your reference.

1. Main Steps
1. view the current Windows version and architecture
Wmic OS get caption
Wmic OS get osarchitecture

2. Download the corresponding version
Http://www.mongodb.org/downloads

3. Configure mongdb
Create a path for storing data files
Md \ data \ db
You can specify an alternate path for data files using the-dbpath option to mongod.exe, for example:
C: \ mongodb \ bin \ mongod.exe-dbpath d: \ test \ mongodb \ data

If your path contains des spaces, enclose the entire path in double quotes, for example:
C: \ mongodb \ bin \ mongod.exe-dbpath "d: \ test \ mongo db data"

4. Start mongodb
To start MongoDB, run mongod.exe. For example, from the Command Prompt:
C: \ mongodb \ bin \ mongod.exe
This starts the main MongoDB database process. The waiting for connections message in the console
Output indicates that the specified d.exe process is running successfully.

5. Connect to mongodb
To connect to MongoDB through the cmd.exe shell, open another Command Prompt.
C: \ mongodb \ bin \ cmd.exe

6. Terminate mongodb
Later, to stop MongoDB, press Control + C in the terminal where the specified D instance is running

Ii. Main Components of Mongodb
Component Set Binaries
-----------------------------------
Server cmdd.exe
Router mongos.exe
Client cmd.exe
MonitoringTools mongostat.exe, mongotop.exe
ImportExportTools mongodump.exe, mongorestore.exe, export export.exe,mongoimport.exe
MiscellaneousTools bsondump.exe, cmdfiles.exe, cmdoplog.exe, mongoperf.exe

3. Configure Mongodb as a Windows Service
Step 1: Open an Administrator command prompt ### Open a command line window
Step 2: Create directories. ### Create a database data and log directory
Mkdir c: \ data \ db
Mkdir c: \ data \ log
Step 3: Create a configuration file ### Create a configuration file
Create a configuration file. The file must set systemLog. path. Include additional configuration options as appropriate.
For example, create a file at C: \ mongodb \ mongod. cfg that specifies both systemLog. path and storage. dbPath:
SystemLog:
Destination: file
Path: c: \ data \ log \ mongod. log
Storage:
DbPath: c: \ data \ db

Step 4: Install the MongoDB service.
Install the MongoDB service by starting mongod.exe with the -- install option and the-config option
Specify the previusly created configuration file.
"C: \ mongodb \ bin \ mongod.exe" -- config "C: \ mongodb \ mongod. cfg" -- install

Step 5: Start the MongoDB service.
Net start MongoDB

Step 6: Stop or remove the MongoDB service as needed.
To stop the MongoDB service use the following command:
Net stop MongoDB
To remove the MongoDB service use the following command:
"C: \ mongodb \ bin \ mongod.exe" -- remove

Iv. Installation demonstration
1. Installation
C: \ Users \ 1636> wmic OS get caption
Caption
Microsoft Windows 7 Ultimate

C: \ Users \ 1636> wmic OS get osarchitecture
OSArchitecture
64-bit

Use the downloaded msi file to start installation in the specified folder. In this example, D: \ MongoDB \ Server \ 3.0 \

2. Configure Environment Variables
// Add D: \ MongoDB \ Server \ 3.0 \ bin to the system environment variable PATH in this example.
; D: \ MongoDB \ Server \ 3.0 \ bin

D: \> mkdir d: \ MongoDB \ data
D: \> d: \ MongoDB \ Server \ 3.0 \ bin \ mongod.exe -- dbpath d: \ MongoDB \ data
2015-10-29T09: 26: 11.498 + 0800 I CONTROL Hotfix KB2731284 or later update is not installed, will zero-out data files
2015-10-29T09: 26: 11.508 + 0800 I JOURNAL [initandlisten] journal dir = d: \ MongoDB \ data \ journal
2015-10-29T09: 26: 11.509 + 0800 I JOURNAL [initandlisten] recover: no journal files present, no recovery needed
2015-10-29T09: 26: 11.611 + 0800 I JOURNAL [durability] Durability thread started
2015-10-29T09: 26: 11.613 + 0800 I JOURNAL [journal writer] Journal writer thread started
2015-10-29T09: 26: 11.718 + 0800 I CONTROL [initandlisten] MongoDB starting: pid = 40540 port = 27017
Dbpath = d: \ MongoDB \ data 64-bit host = hq1636
2015-10-29T09: 26: 11.719 + 0800 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2015-10-29T09: 26: 11.722 + 0800 I CONTROL [initandlisten] db version v3.0.6
2015-10-29T09: 26: 11.725 + 0800 I CONTROL [initandlisten] git version: 1ef45a23a4c5e3480ac919b28afcba3c615488f2
2015-10-29T09: 26: 11.728 + 0800 I CONTROL [initandlisten] build info: windows sys. getwindowsversion (major = 6,
Minor = 1, build = 7601, platform = 2, service_pa
Ck = 'service Pack 1') BOOST_LIB_VERSION = running 49
2015-10-29T09: 26: 11.731 + 0800 I CONTROL [initandlisten] allocator: tcmalloc
2015-10-29T09: 26: 11.737 + 0800 I CONTROL [initandlisten] options: {storage: {dbPath: "d: \ MongoDB \ data "}}
2015-10-29T09: 26: 11.906 + 0800 I NETWORK [initandlisten] waiting for connections on port 27017
// This indicates that mongodb has started waiting for connection

Open a separate cmd window and use the mongo client to connect to mongod.
C: \ Users \ 1636> d: \ MongoDB \ Server \ 3.0 \ bin \ cmd.exe
2015-10-29T09: 28: 12.427 + 0800 I CONTROL Hotfix KB2731284 or later update is not installed, will zero-out data
Files
MongoDB shell version: 3.0.6
Connecting to: test // The connection is successful.
> Db. version ()
3.0.6
> Show dbs
Local 0.078 GB
// If You Need To Stop mongod at this time, you can simply use ctrl + c in the original window.
3. Add Mongodb as a Windows Service
D: \> mkdir d: \ MongoDB \ data
D: \> mkdir d: \ MongoDB \ log
D: \> -- Author: Leshami
D: \> -- Blog:

For more information about MongoDB, see the following links:

MongoDB 3.0 official version released and downloaded

CentOS compilation and installation of MongoDB

CentOS compilation and installation of php extensions for MongoDB and mongoDB

CentOS 6 install MongoDB and server configuration using yum

Install MongoDB2.4.3 in Ubuntu 13.04

MongoDB beginners must read (both concepts and practices)

MongoDB Installation Guide for Ubunu 14.04

MongoDB authoritative Guide (The Definitive Guide) in English [PDF]

Nagios monitoring MongoDB sharded cluster service practice

Build MongoDB Service Based on CentOS 6.5 Operating System

MongoDB details: click here
MongoDB: click here

This article permanently updates the link address:

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.