Section 1 Introduction, download, and installation of MongoDB

Source: Internet
Author: User
Tags install mongodb mongodb latest version mongodb server
    • 1. Download
    • Ii. Installation


MongoDB is a product between relational databases and non-relational databases. It has the most abundant functions and features like relational databases. The supported data structure is very loose and is similar to the JSON bjson format. Therefore, it can store complicated data types. The biggest feature of Mongo is that it supports a very powerful query language. Its syntax is somewhat similar to an Object-Oriented Query Language. It can almost implement most of the functions similar to single-table queries in relational databases, it also supports data indexing.

It features high performance, ease of deployment, and ease of use, making it easy to store data. Features:

    • It is designed for centralized storage and is easy to store object-type data.
    • Free mode.
    • Supports dynamic query.
    • Supports full indexing, including internal objects.
    • Query is supported.
    • Supports replication and fault recovery.
    • Use efficient binary data storage, including large objects (such as videos ).
    • Automatic fragment processing to support scalability at the cloud computing level
    • Supports Ruby, Python, Java, C ++, PHP, and other languages.
    • The file storage format is bson (a json extension)
    • Accessible through the network

The so-called "collenction-orented" means that data is stored in a data set by groups and is called a collection ). Each set has a unique identification name in the database and can contain an infinite number of documents. The concept of a set is similar to that of a table in a relational database service (RDBMS). The difference is that it does not need to define any schema ).
Schema-free means that we do not need to know any schema definitions for the files stored in the MongoDB database. If necessary, you can store files of different structures in the same database.
The document stored in the set is saved as a key-value pair. The key uniquely identifies a document, which is a string type, and the value can be a complex file type. We call this storage form bson (Binary serialized document format ).

The MongoDB server can run on Linux, windows, or OS X. It supports 32-bit and 64-bit applications. The default port is 27017. It is recommended to run on a 64-bit platform because MongoDB

The maximum file size supported when running in 32-Bit mode is 2 GB.

MongoDB stores data in files (the default path is/data/DB) and uses memory ing files for management to improve efficiency.

The above is a non-traditional non-relational database. Now it is classified as a document database. Note that the maximum file supported by 32-bit operating systems is 2 GB, therefore, if you want to store large files, you need to install the 64-bit system. Let's start the download and installation process.

1. Download

MongoDB's official website is:

MongoDB Latest Version Download in the official download menu:

I chose Windows 32-bit 1.8.1.

MongoDB for. Net driver development kit is located in the official driver menu (including other language development links):

Windows 7 Professional Edition, Windows 32-bit 1.8.1, and vs2008

We started the installation process.

Ii. Installation

1.decompress, create path c: \ Program Files \ MongoDB, and copy the decompressed binfile to this folder.

2. c: \ Program Files \ create a data folder C: \ Program Files \ MongoDB \ data under MongoDB, and then create two folders dB and log respectively. At this point, MongoDB has the following folders:

C: \ Program Files \ MongoDB \ bin

C: \ Program Files \ MongoDB \ data \ DB

C: \ Program Files \ MongoDB \ data \ log

Create a log file MongoDB. log in the log folder, that is, c: \ Program Files \ MongoDB \ data \ log \ MongoDB. Log

After completing the above work, you wonder why you need to create these folders (because these folders are required for MongoDB installation, which are not created by default, but all files are installed under c: \ data)


3. Several installation methods

3.1ProgramStartup Mode

Run cmd.exe to enter the DOS hit page.

> Cd c: \ Program Files \ MongoDB \ bin

> C: \ Program Files \ MongoDB \ bin> mongod-dbpath "C: \ Program Files \ MongoDB \ data \ DB"

Run this command to create the MongoDB database file to the C: \ Program Files \ MongoDB \ data \ dB directory. The success prompt of sucess in the last line of the command is displayed unexpectedly.

The primary data library is started. This interface is the Startup Program of the primary database. You can directly double-click mongod.exe after closing the interface (note that it is D. This is the Startup Program)

After the program is started, run the cmd.exe Program (note that there is no D). The interface is as follows:

Test Database Operations

> Help (view related information)

> DB. Foo. insert ({A: 1}) (insert a and 1 field values to the foo table. The Foo table is the default table)

> DB. Foo. Find () (view Foo table data)

The result is as follows:

We can see that three records are inserted: A, CCTV, and set.

When mongod.exeis closed, mongo.exe cannot be connected to the Data Warehouse. Every time I want to use mongodbdata warehouse, I want to open mongod.exe.

Install MongoDB as a Windows Service

3.2 Windows Service

Run cmd.exe

> Cd c: \ Program Files \ MongoDB \ bin

> C: \ Program Files \ MongoDB \ bin> mongod -- dbpath "C: \ Program Files \ MongoDB \ data \ DB" -- logpath "C: \ Program Files \ MongoDB \ data \ log \ MongoDB. log "-- install -- servicename" MongoDB"

Here, MongoDB. log is the log file that was created. -- servicename "MongoDB" is named MongoDB.

The command is successfully run as follows:

The service is successfully installed and runs

> Net start MongoDB (enable service)

> Net stop MongoDB (disable Service)


> C: \ Program Files \ MongoDB \ bin> mongod -- dbpath "C: \ Program Files \ MongoDB \ data \ DB" -- logpath "C: \ Program Files \ MongoDB \ data \ log \ MongoDB. log "-- remove -- servicename" MongoDB "(delete, note that it is not -- install)

For other commands, refer to the Help Command or the instructions on the official website.

View services

Run the cmd.exe client under the binfolder to test it. The test is the same as 3.1.

3.3 daemon Creation

-- Fork runs MongoDB as a daemon and creates Server Processes

> C: \ Program Files \ MongoDB \ bin> mongod -- Port 10220 -- fork -- dbpath "C: \ Program Files \ MongoDB \ data \ DB" -- logpath "C: \ Program Files \ MongoDB \ data \ log \ MongoDB. log"

Forked process: 44086

All output going to: MongoDB. Log

The installation is complete.

4. Stop MongoDB

The most secure method is to process all current operations and save the cached data to the disk.

> User admin

> DB. shutdownserver ();

of course, we can also directly shut down the process, but this method will cause the cache data to be refresh and saved to the disk when it is not in a hurry and lost. The next chapter is developed by Mongo for. net.

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