8-day learning MongoDB (actual operation version)-First-day Basics

Source: Internet
Author: User
Tags mongodb download mongodb server

In order to facilitate the practice, we will follow the "8-day learning MongoDB" series of actual operations and make learning diary records.

I. Download

Go to the official MongoDB download page, which has 32-bit and 64-bit versions. Pay attention to the following:

    1. According to industry rules, the even number is "stable version" (for example, 1.6.x, 1.8.x), and the odd number is "development version" (for example, 1.7.x, 1.9.x ), I believe everyone knows the difference between the two versions.
    2. 32-bit MongoDB can only store up to 2 GB of data, with no limit on 64-bit data.

I chose the 64-bit version 2.0.4. Decompress the package to drive C and change the folder name to MongoDB.

 

Ii. Start

    1. Before startup, add a sub-directory DB under the c: \ MongoDB directory to store MongoDB data.
    2. In the command line, enter the followingCode
      CodeCd c: \ MongoDB \ binmongod -- dbpath = c: \ MongoDB \ DB

    3. Finally, check whether it is enabled successfully. The information shows that MongoDB uses port 27017. Then, type "http: // localhost: 27017/" in the browser, mongoDB tells us that you can use http mode to view MongoDB Management Information (http: // localhost: 27017/) on add 1000 /)

III. Basic operations

Next we will try to add, delete, query, and modify MongoDB. mongod is started on the MongoDB server.ProgramMongo is the MongoDB shell, which can be considered as a client and a JS compiler. It is connected to the Test Library by default.

 
CodeCd c: \ MongoDB \ binmongo

    1. Insert operation
      DB. Person. insert ({"name": "Jack", "Age": 20 })
      DB. Person. insert ({"name": "Joe", "Age": 25 })
      The above two lines of commands insert two lines of records into the set person. Note that if the set person does not exist, a new one will be created directly.
    2. Find operation
      DB. Person. Find ()
      DB. Person. Find ({"name": "Joe "})
      The find method without any parameters lists all records in the set.
    3. Update operation
      DB. Person. Update ({"name": "Joe" },{ "name": "Joe", "Age": 35 })
      Note that the second parameter in update, that is, the target value, must contain a complete field. Otherwise, other fields will become null.
    4. Remove operation
      DB. Person. Remove ()
      Note that this operation will delete all data without any parameters and cannot be withdrawn.
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.