Basic use of MongoDB----Flying Blog

Source: Internet
Author: User
Tags mongo shell

Mongo 's introduction: This MongoDB website said good ah,MongoDB is an open source document -based database , and is a good NoSQL database, and it is written in C + + , very efficient. What are some of the characteristics?

Full index support, ability to index no matter what property

Replication and high availability for LAN and WAN extensions

Self-sharing, can linearly scale without affecting his function

Query, Rich query

High-speed updates

Map/reduce

Gridfs

MongoDB Management Service specifically for MongoDB Management and backup of the service

Since there are so many characteristics, let's have a look at the preliminary

First download MongoDBfrom the official website, I am here is the win7 of :/http Www.mongodb.org/downloads Download Down is the msi file mongodb-win32-x86_ 64-2008plus-2.6.4-signed.msi

Then, execute this installation file. Follow the prompts to install it, there is a need to choose. Because it is basic, it is possible to choose a type of installation .

Last point finish

Next is the opening and use of the MongoDB service. Say here, I naturally think of the possibility of MongoDB installation in the Windows Service there to register a mongodb Service, The result is a look, no. That's a rip-off. So how do we start the service?

The service side and client side of this MongoDB are several exe files. and put it together. Turn on the service to open it.

First specify the Data directory of MongoDB, build the mongodb Data directoryon D disk :D:\mongo\ Data

Then go to the Bin folder of the MongoDB home and tap the following command:

Mongod.exe--dbpath D:\mongodb\data

Note that if your data file has spaces, add a double argument to the path

Suppose you see a similar interface like the following, which indicates that the service has been successfully opened

Prompted above. waiting for connections on port 27017

Next, connect to the MongoDB

Into the bin folder,mongo.exe can

It will appear such as the following interface

There is information on the server side, of course, can also be seen (1 connection now OPEN)

That means the connection is successful.

Here are some commands:

Mongo Shell has some functions similar to normal databases,

For example, show DBS to see what the current database is

Use MyDB using mydb This database

DB confirms current database

Suppose there is data to be inserted, can be like the following operations:

> DB

MyDB

> K={x:3}

{"X": 3}

> Db.mydb.insert (k)

Writeresult ({"ninserted": 1})

>

So the insertion is successful.

then show collections;

The current database collection and index are displayed

> Show Collections;

MyDB

System.indexes

Find data

> Db.mydb.find ()

{"_id": ObjectId ("53eb58a53a8f3927b8de97a0"), "name": "MONGO"}

{"_id": ObjectId ("53eb6681051885f61818992a"), "X": 3}

MongoDB agrees to operate like a javascprit script. Don't believe it. You can try, huh?

Something else. For example, configuration. Let's not say it, but write it later.

In addition, if reproduced please indicate the source http://blog.csdn.net/xh199110

Basic use of MongoDB----Flying Blog

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.