MongoDB primary (brief introduction to installing and using MongoDB in Linux)

Source: Internet
Author: User

MongoDB introduction:

Non-relational databases are mainly used to solve the following problems:

A) High database concurrency requirements

B) Demand for efficient storage and access to massive data

C) high scalability and availability requirements for Databases

Disadvantages:

A) Database Transaction consistency requirements

B) database write timeliness and read timeliness requirements

C) complex SQL queries, especially multi-table join queries

Differences between MongoDB and relational database storage:



1. Download MongoDB

Http://www.mongodb.org/downloads when I sent this blog I used 1.8.2, using Linux 64-bit

2. Run Server

Decompress the downloaded MongoDB file, decompress it to/usr/local/MongoDB, and start the/bin/mongod server.

Below are some parameters I added during startup:

You need to create two folders: data and data/MongoDB (this may be the main reason why you cannot afford the MongoDB service)

./mongod -dbpath=../data/mongodb -logpath=../data/mongodb/mongodb.log -directoryperdb>/dev/null 2>&1.

--> Parameter explanation: dbpath (data storage directory) logpath (Log Path) directoryperdb (each database is stored in a different directory)

3. Run MongoDB

It's easy to run. Run/bin/Mongo directly.

4. Simple SQL Testing

> Show DBS ---> query the current database admin (empty) Local (empty)> use crazy --> switch the database at will, switched to DB crazy> show DBS --> View crazy database again. Admin (empty) Local (empty)> dB is not created. crazy. insert ({A: 3, B: 5}) -- insert data to the crazy table in the crazy database> show DBS admin (empty) crazy 0.203125 GB -- crazy database created successfully local (empty)> dB. createcollection ("baby") -- create the baby data table {"OK": 1}> show collections babyblogsystem. indexes> dB. crazy. find () -- Query all data in the crazy table {"_ id": objectid ("4d99dc8a6c0c727c06c3b618"), "A": 3, "B": 5}
> Use tutorial -- unmount a database first, go to switched to DB tutorial> dB. dropdatabase () -- unmount {"dropped": "tutorial", "OK": 1}
 

Create collection: DB. createcollection ('good ')

For other usage, use help and DB. Help ()

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.