Introduction to NoSQL (vii)
MongoDB Introduction
- Official website www.mongodb.com
- C + +, based on distributed, belongs to a NoSQL
- In NoSQL, it's the most like relational database.
- MongoDB stores data as a document, and data structures are composed of key-value (key=>value) pairs. A MongoDB document is similar to a JSON object. Field values can contain other documents, arrays, and document arrays.
- Because it's distributed, it's easy to scale
Comparison of MongoDB and relational databases
SQL Terminology Concepts |
MongoDB Terminology Concepts |
Explanatory notes |
Database |
Database |
Database |
Table |
Collection |
Database Tables/Collections |
Row |
Document |
Data record lines/documents |
Column |
Filed |
Data fields/Fields |
Index |
Index |
Index |
Table joins |
|
Table Connection MongoDB does not support |
Primary key |
Primary key |
Primary key MongoDB automatically sets the _id field as the primary key |
MongoDB Installation
Official Installation Documentation https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/
vim /etc/yum.repos.d/mongodb-org-3.6.repo[mongodb-org-3.6]name=MongoDB Repositorybaseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/x86_64/gpgcheck=1enabled=1gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc
yum list | grep mongodbyum install -y mongodb-org
MongoDB Connection
systemctl start mongod.servicenetstat -tlnp|grep mongodtcp 0 0 192.168.221.10:27017 0.0.0.0:* LISTEN 1999/mongod tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN 1999/mongodmongo --port 27017 --host 192.168.221.10mongo -uusername -ppasswd --authenticationDatabase db
Introduction to NoSQL (vii)