Ubuntu installation using MongoDB

Source: Internet
Author: User
Tags create directory

installation

Official website Download: https://www.mongodb.org/

Unzip unpack rename to MongoDB move to/usr/local/directory

Create a soft connection

ln-s/usr/local/mongodb/bin/mongod/usr/bin/mongod for mobile server

ln-s/usr/local/mongodb/bin/mongo/usr/bin/mongo for starting the client (shell)

Create directory sudo mkdir-p/data/db is the default startup database path for MongoDB (--dbpath)

Start service $ sudo mongod

Start the client shell $ MONGO

Start HTTP Web UI $ sudo mongod--rest

Basic Concepts
SQL Terminology/Concepts MongoDB Terminology/Concepts Explanation/Description
Database Database Database
Table Collection Database Tables/Collections
Row Document Data record lines/documents
Column Field Data fields/Fields
Index Index Index
Table joins Table connection, MongoDB not supported
Primary key Primary key Primary key, MongoDB automatically sets the _id field as the primary key

A more intuitive reflection of the correspondence between SQL and MongoDB

Basic syntax
 > DB #显示当前所在数据库, default is Test 

> use database_name #切换数据库, if the name does not exist, it is equivalent to creating a new database (which is not saved until the collection is created)

> Show dbs/>show databases #查看所有的数据库

> db. collection_name insert ({' xx ': ' oo '}) #创建集合 inserted content formatted as key/value pairs

> db. collection_name Insert (document) #向集合中插入文档 as above

> db. Collection_name.find () #查看已插入的文档

> db.col. (). Pretty () #易读方式查询文档

> db. Dropdatabase () #删除数据库







Ubuntu installation using MongoDB

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.