mongodb on linux for the first time

Purpose: it's not a professional one. Take it and play. If it's really put into production, please move to the official website

Reference: Official website Doc The document is very rich, only look for the simplest

Mapping question: "put the elephant in the refrigerator. How many steps are there?"

The first step is to open the refrigerator door, the second step is to install the elephant, the third step is to close the refrigerator door;

Question: "how many steps are there to play mongodb?"

Step 1: install mongodb; step 2: run mongodb and connect it; step 3: play, play slowly;

1, install on Linux:

1. Configure the package management system
Create a /etc/yum.repos.d/mongodb-org-4.2.repo file.

	name=MongoDB Repository

2. Install the MongoDB packages.
    sudo yum install -y mongodb-org

After installation, all configurations are default.... file saving directory, log saving directory

Two. Run

	1. Start MongoDB.
	sudo systemctl start mongod
	 -- sudo systemctl daemon-reload
	2. Verify that MongoDB has started successfully.
	sudo systemctl status mongod
	--  sudo systemctl enable mongod
	3. Stop MongoDB
	sudo systemctl stop mongod
	4. Restart MongoDB
	sudo systemctl restart mongod
	5. Begin using MongoDB

Only local connections are allowed by default

connection remotely

vim /etc/mongod.conf

bind_ip= --> bind_ip=

//IP to connect: x.x.x.xx

//Command: mongo x.x.x.xx:27017

How to delete and move to the official website? Pipe digging, regardless of burying, has always been a good style of our programmers

Three. Opt

use examples; -- Create Library

-- insert 
   { item: "journal", qty: 25, status: "A", size: { h: 14, w: 21, uom: "cm" }, tags: [ "blank", "red" ] },
   { item: "notebook", qty: 50, status: "A", size: { h: 8.5, w: 11, uom: "in" }, tags: [ "red", "blank" ] },
   { item: "paper", qty: 10, status: "D", size: { h: 8.5, w: 11, uom: "in" }, tags: [ "red", "blank", "plain" ] },
   { item: "planner", qty: 0, status: "D", size: { h: 22.85, w: 30, uom: "cm" }, tags: [ "blank", "red" ] },
   { item: "postcard", qty: 45, status: "A", size: { h: 10, w: 15.25, uom: "cm" }, tags: [ "blue" ] }

// MongoDB adds an _id field with an ObjectId value if the field is not present in the document

4, basic concepts:

mongodb.db == mysql.database;

mongodb.collection ~~ mysql.table ;

mongodb.?? ~~ mysql.column;

multipulate mongodb by javascript ~~ mysql.SQL

Tags: Programming MongoDB sudo MySQL yum

Posted on Tue, 07 Apr 2020 10:29:13 -0700 by sdyates2001