MongoDB Installation and simple experiments

Source: Internet
Author: User

1.Windows installation of MongoDB

Http://www.mongodb.org/downloads download MSI, next step ...

After installation, to the installation directory of the bin directory execution Mongod start the database service, if not up, error "E:\data\db not found", create a corresponding folder, which is the folder to store the database.

Then start the MONGO database Shell client

2.mongo is a JavaScript interpreter that can run various JS commands directly, such as "x = 200,X/5";

You can also use the JS standard library, such as "Math.sin (MATH.PI/2);";

You can also customize the JS function, such as "function f (n) {return-n;} f (3);"

3.mongo view database, select Database

MONGO supports some non-JS extensions

such as db (view current database name), use DBNAME (switch database)

4.CRUD operation

A. Create:

Post = {"title": "Test", "name", "Yuhk", "Age": 18}

Db.yuhk.insert (POST)// This YUHK is not a database name?

B. Read

Db.yuhk.findOne ()

Db.yuhk.find ()

C. Update

Post.comment = ""//Add Comment field for post

Db.yuhk.update ({"title": "Test"},post)//The first parameter is a query condition, the second parameter is a modified value

After execution, add the Comment field to the original document

D. Delete

Db.yuhk.remove ({}); Delete all

Db.yuhk.remove ({"title": "Test"}); Delete by condition

MongoDB Installation and simple experiments

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.