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 + + ha, very efficient, what are the characteristics of it?

Full index support, can index any property

Replication and high availability, can be extended on LAN and WAN

Auto-sharing, linear scaling without compromising his functionality

Query, Rich query

Quick 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, run this installation file, follow the prompts to install, there is a need to choose, because it is basic use, so the installation type is selected . Last point finish

Next is the opening and use of the MongoDB service, said here, I naturally think that may be in the mongodb installation in the Windows Service there to register a mongodb Service, the results of a look, no, this is a lost. So how do you start the service?

This mongoDB service side and client side is a few exe files, and put together. Turn on the service to open it.

First specify MongoDB Data folder, set up MongoDB data Folders on D disk:d:\ Mongo\data

Then go to the bin directory of the MongoDB home and tap the following command:

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

Note If your data file has spaces, enclose the path with double quotation marks

If you see a similar interface below, it means that the service has been successfully opened.

Tip above,waiting for connections on port 27017

Next, connect to the MongoDB

Into the bin directory,mongo.exe can

You will see 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

If there is data to yo ah insert, you can do as follows:

> 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 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 allows to act like a javascprit script, no letter, you can try Ha

There are some things, such as configuration, will not say, and then write.

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

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.