MongoDB Test Tool

Source: Internet
Author: User

MongoDb is one of the good NoSQL databases. NoSQL means Not Only SQL, which is easier to expand than relational databases such as MySQL and SQL Server, and more suitable for storing massive data, data can be elastically scalable across LAN and WAN, making it more suitable for cloud environments. MongoDB needs to be used in a recently started project. Here, we will try to install and test it on the local machine.

 

MongoDB can be downloaded from the official website and decompressed to a directory, such as C: \ MongoDB. To run MongoDB, create two directories:

C: \ MongoDB \ data is used to store data
C: \ MongoDB \ log used to store logs

 

Then go to the command line:
C: \ MongoDB \ bin> mongod.exe -- dbpath c: \ mongodb \ data

The server can be started.

 

Then open a cmd window, run mongo, and connect to the server:

C: \> cd MongoDB

C: \ MongoDB> cd bin

C: \ MongoDB \ bin> mongo
MongoDB shell version: 2.4.3
Connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help ".
For more comprehensive documentation, see
Http://docs.mongodb.org/
Questions? Try the support group
Http://groups.google.com/group/mongodb-user

 

NoSQL such as MongoDB is different from common relational databases. It does not have a fixed structure but is saved in the form of documents. The following is a test example:
> Db. test. save ({a: 1}); // save a record a = 1 in the test table (for the moment ).

> Db. test. find (); // query all records
{"_ Id": ObjectId ("517b4b3823c489619d958d66"), "a": 1}
>

Add several more records. Note that these new records contain several more fields:

> Db. test. save ({name: 'lisi', score: 87, grade: 'good '});
> Db. test. save ({name: 'hangw', score: 61, grade: 'pass '});

> Db. test. find ();
{"_ Id": ObjectId ("517b4b3823c489619d958d66"), "a": 1}
{"_ Id": ObjectId ("517b4eba23c489619d958d67"), "name": "zhang san", "score ":
93}
{"_ Id": ObjectId ("517b4f3523c489619d958d68"), "name": "lisi", "score": 87 ,"
Grade ":" good "}
{"_ Id": ObjectId ("517b4f5023c489619d958d69"), "name": "wangwu", "score": 61,
"Grade": "pass "}
>

 

We can see that MongoDB is very flexible to use. The specific usage will be further studied.

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.