MongoDB installation, curd operation, usage Scenario Analysis Summary (1)

Source: Internet
Author: User
Tags mongodb commands mongodb server

NoSQL (NoSQL = not-only sql), meaning "not just sql." Non-relational data storage

MongoDB is a database based on distributed file storage. Written by the C + + language. Designed to provide scalable, high-performance data storage solutions for WEB applications.

MongoDB is a product between a relational database and a non-relational database, and is the most versatile and most like relational database in a non-relational database.

MongoDB has database, collection, document three basic concepts are equivalent to the database, table, row in a relational database.

One, MongoDB installation

MongoDB Website: https://www.mongodb.org/downloads

The latest version of Windows is 3.2.0, if you don't see this download option, try a few more browsers.

After the download is finished, click Mongodb-win32-x86_64-2008plus-ssl-3.2.0-signed.msi Installation, the next installation can be a fool, the default load to C:\Program files\mongodb\server\3.2 Under \ bin.

Microsoft logo +r, enter cmd as follows command:

The "CD C:\Program Files\mongodb\server\3.2\bin"--version returns to the MongoDB shell version:3.2.0 instructions to install successfully.

In the browser type "http://localhost:27017/", the following interface appears, also indicates that the installation was successful.

After successful installation, it is convenient to add MONGODB commands to the environment variable path

My Computer--right----Properties such as:

When correctly added, cmd direct input MONGO--version returns to MongoDB shell version:3.2.0

Second, create the data directory, log directory

MongoDB stores the data directory in the DB directory. However, this data directory is not actively created, we need to create it after the installation (data, DB, log folder does not create will be error, below).

Data Catalog: C:\Program files\mongodb\data\db

Log directory: C:\Program files\mongodb\log\log.txt

Execute the following command:

Mongod--dbpath "C:\Program files\mongodb\data\db"--logpath "C:\Program files\mongodb\log\log.txt"--logappend

Third, run the MongoDB server as a Windows service

Execute the following command:

Mongod--dbpath "C:\Program files\mongodb\data\db"--logpath "C:\Program files\mongodb\log\log.txt"--logappend-- Directoryperdb--servicename MongoDB--install

Failed to start as Windows Service: Windows cannot start MongoDB on the local computer, error code 100

Workaround:

1, the MongoDB installation directory \data\ The Mongod.lock under this folder is deleted

2, check whether set data directory dbpath or log directory LogPath is correct

Iv. curd operation of MongoDB

1. Insert--cmd, enter MONGO command to open the shell, use TestDB. The document must be in the form of a JSON extension (Bson)

Db.person.insert ({"Name": "joye888", "Age": "25"})

Db.person.insert ({"Name": "joye888", "Age": "26"})

2, query--"_id": Database plus the GUID of the primary key

Db.person.find ()

3. Modification

Update ({query criteria},{what needs to be modified})

4. Delete

Db.person.remove ({})--Delete all

Db.person.remove ({"Name": "joye888"})--delete based on condition

V. MongoDB usage Scenarios:

Suitable for the scene:

1. Storage for objects and JSON data

2, large-size, low-value data

3, cache, such as examination of the Test bank

4. Log data

Non-used scenarios:

1. Highly-functional systems: Banking systems

2. Data that requires highly optimized queries

3. Important Data

4, need complex SQL to solve the problem

MongoDB installation, curd operation, usage Scenario Analysis Summary (1)

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.