MongoDB Learning Notes (I.) Introduction and installation method of MongoDB

Source: Internet
Author: User
Tags arrays failover json mongodb port number
Recently began to learn the MongoDB database, but in the blog Park can not find a comparative system of tutorials, a lot of information to go to the English site, the efficiency is relatively low. I am not, by the opportunity to self-study experience are recorded, to facilitate the interest of children's shoes sharing discussion

First, the preface

Recently began to learn the MongoDB database, but in the blog Park can not find a comparative system of tutorials, a lot of information to go to the English site, the efficiency is relatively low. I am not, by the opportunity to self-study experience are recorded to facilitate the interest of children's shoes sharing discussions. Some resources from other blogs, the purpose of the scattered knowledge points together, if there is infringement of your rights, please contact Most of the content is original, you are welcome to reprint share, but reproduced at the same time do not forget to mention the author and the original link oh.

Ii. introduction of MongoDB

MongoDB is a high-performance, open source, modeless document database, is the current NoSQL database is a more popular one. It can be used to replace traditional relational database or key/value storage in many scenarios. MONGO uses C + + development. MONGO's official website address is:, where readers can get more detailed information.

Episode: What is NoSQL?

NOSQL, the full name is not just SQL, refers to the database of non relational type. The next generation database mainly solves several main points: non-relational, distributed, open source, level scalable. The original purpose was for large-scale Web applications, which began in the early 2009, with typical features such as free mode, support for easy replication, simple APIs, final consistency (non-acid), bulk data, and so on. NoSQL is the most used Key-value storage, of course, there are other document-type, column storage, graph database, XML database and so on.


High-performance, easy to deploy, easy to use, storage data is very convenient. The main functional characteristics are:

• Set-oriented storage for easy storage of object-type data.
• Model Freedom.
• Support dynamic queries.
• Supports full indexing, containing internal objects.
• Support Queries.
• Support for replication and recovery.
• Use efficient binary data storage, including large objects such as video.
• Automatically process fragmentation to support cloud level scalability
• Supports Python,php,ruby,java,c,c#,javascript,perl and C + + language drivers, and the community also provides drivers for Erlang and. NET platforms.
• The file storage format is Bson (an extension of JSON).
• Accessible over the network.


• Collection-oriented storage: suitable for storing objects and JSON-style data.
• Dynamic query: MONGO supports rich query expressions. Query directives use JSON-form tags to easily query objects and arrays that are embedded in the document.
• Full index support: Includes document inline objects and arrays. The MONGO query optimizer analyzes the query expression and generates an efficient query plan.
• Query monitoring: MONGO contains a monitoring tool for analyzing the performance of database operations.
• Replication and automatic failover: The MONGO database supports data replication between servers, supporting master-from-mode and server replication. The primary goal of replication is to provide redundancy and automatic failover.
• Efficient traditional storage: support for binary data and large objects (such as photos or pictures)
• Automatic fragmentation to support cloud-level scalability: automatic fragmentation supports a level of database clustering that can dynamically add additional machines.

Applicable occasions:

• Site data: MONGO is ideal for real-time inserts, updates, and queries, as well as the replication and high scalability required for real-time data storage on the Web site.
• Caching: Because of its high performance, MONGO is also suitable as a caching layer for the information infrastructure. After the system restarts, the persistent cache layer built by MONGO can avoid overloading the underlying data source.
• Large size, low value data: It may be expensive to store some data using a traditional relational database, before which programmers often choose traditional files for storage.
• Highly scalable scenario: MONGO is ideal for databases made up of dozens of or hundreds of servers. The MONGO roadmap already contains built-in support for the MapReduce engine.
• Storage for objects and JSON data: MONGO's Bson data format is ideal for storing and querying in a documented format.

Third, download the installation and configuration

To install the MONGO database:

The most recent version available at the time of publishing this article is: 1.6.5, if you do not make a special statement, the version used in this tutorial will be this version.

1. The first step: Download the installation package: The official download address ← Click here, if the win system, note that the 64-bit or 32-bit version, please select the correct version.
2. The second step: Create a new directory "D:mongodb", unzip the download to the installation package, find the bin directory all the. exe file, copy to the directory just created.
3. Step three: Create a new "data" folder in the "D:mongodb" directory, which will be used as the root folder for data storage.
Configure the MONGO service side:

Open the cmd window and enter the command as follows:
> D:
> CD D:mongodb
> Mongod--dbpath d:mongodbdata

When the configuration succeeds, you will see the following screen:

in the browser input: http://localhost:27017/, you can see the following prompts:
You are trying to access MongoDB on the native Dr Iver Port. For HTTP diagnostic access, add 1000 to the port number

, the MongoDB database service has started successfully.

Four, PostScript

Now we have the initial implementation of MongoDB installation and service start-up work. We still have a lot of work to do, to make MongoDB in our C # code can be manipulated, but also need to drive, often have friends in the online copy code found that the compiler does not pass, it is estimated that the driver is inconsistent, the next article will be explained in detail, not to be continued.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.