MongoDB Quick Start

Source: Internet
Author: User
Tags install mongodb mongodb mongodb server win32

NoSQL of the MONGODB study:


MongoDB is a cross-platform, document-oriented database that delivers high performance, high availability, and ease of scaling. MongoDB is a concept that works on collections and documents. Number of data

A database is a physical container for a collection. Each database gets its own files that are set on the file system. A single MongoDB server typically has multiple databases. Collection

A collection is a set of MongoDB files. It is equivalent to an RDBMS table. A collection exists in the database. The collection does not enforce the pattern. The documents in the collection can have different fields. In general, all files in a collection are similar or related purposes. Document

A document is a set of key-value pairs. The document has dynamic mode. Dynamic mode means that a file in the same collection does not have to have a document field or structure with the same set of collections, and that the same fields can hold different types of data. Sample Document

The following example shows a blog site that is simply a comma-delimited document structure for key-value pairs.

{
   _id:objectid (7df78ad8902c)
   title: ' MongoDB Overview ', 
   Description: ' MongoDB is no SQL database ', by
   : ' Yiibai tutorial ',
   URL: ' http://www.yiibai.com ',
   Tags: [' mongodb ', ' database ', ' NoSQL '],
   likes:100, 
   comments: [	
      {
         User: ' user1 ', message
         : ' I-comment ',
         datecreated:new Date (2011,1,20,2,15 ),
         like:0 
      },
      {
         User: ' User2 ', message
         : ' My second comments ',
         datecreated:new Date ( 2011,1,25,7,45),
         like:5
      }
   ]
}
Install the MongoDB on Windows

To install MongoDB on Windows, first download the latest version of MongoDB from Http://www.mongodb.org/downloads

Now, extract the downloaded files to the C:\ drive or other location. Make sure the compressed folder name is Mongodb-win32-i386-[version] or mongodb-win32-x86_64-[version]. Here [version] is the download version of MongoDB.

Now open the command prompt and run the following command

C:\>move mongodb-win64-* MongoDB
      1 dir (s) moved.
C:\>

If extracting mondodb in a different location, then enter this path through the command CD Foolder/dir now run the process given above.
The following is a simple installation step, the first step:



Step Two: Select Custom Install (you can define your own installation directory)



Step Three: Select the installation directory




Fourth Step: Select installation directory



Fifth Step: Installation complete.


If you install MongoDB in a different location (recommended to D:\software), you need to set the path DBPath to point to the data alternate path in Mongod.exe. Please take a look at the following command

At the command prompt, navigate to the Bin directory, which is currently to the MongoDB installation folder. The installation folder in this tutorial is (to keep it consistent with this tutorial, it is recommended to install to this directory, if you like toss, then I can not stop it): D:\software

C:\users\yiibai>d:
d:\>cd "Software"
d:\software>cd Mongodb\server\3.0\bin

This will show the console output message waiting for the connection, indicating that Mongod.exe successfully ran the process.

Now running the MongoDB, you need to open a command prompt and issue the following command

D:\software\mongodb\server\3.0\bin>mongo.exe
MongoDB Shell version:3.0.4
connecting to:test
> Db.test.save ({a:1})
>db.test.find ()
{"_id": ObjectId (5879b0f65a56a454), "a": 1}
>

This will show the installed MongoDB and run successfully. The next time you want to run MongoDB you only need to issue a command:

d:\software\mongodb\server\3.0\bin>mongod.exe--dbpath" d:\software\ Mongodb\server\3.0\data "D:\software\mongodb\server\3.0\bin>mongo.exe 

Error occurred:

D:\software\mongodb\server\3.0\bin>mongod.exe--dbpath "D:\software\MongoDB\Server\3.0\data" 2015-07-11t08 : 47:22.896+0800 I Control Hotfix KB2731284 or later update are not installed, would zero-out data files 2015-07-11t08:47:22 .896+0800 I STORAGE [Initandlisten] exception in initandlist en:29 Data directory D:\software\MongoDB\Server\3.0\data No T found., terminating

Workaround: Create a new directory under the D:\software\MongoDB\Server\3.0\ directory: Data
Note: A new command line window is opened to perform various commands for MongoDB.


Creating a database

MongoDB use database_name is used to create a database. This command creates a new database if the database does not exist, otherwise the existing database is returned. Grammar

The basic syntax for the USE database statement is as follows:

Use database_name
Example:
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.