Tutorial on installing mongodb under linux

Tutorial on installing mongodb under linux

MongoDB is cross-platform and can be installed on both Windows and Linux. Here we focus on the installation of MongoDB under Linux.

**

1.MongoDB provides 64-bit installation packages for various Linux distributions. You can download the installation package from the official website.

curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.2.12.tgz 

insert image description here

It took me 27 minutes to download. . . .

2. The default download path is to the Downloads directory under the user directory, unzip it

tar -zxvf mongodb-linux-x86_64-3.2.12.tgz 

insert image description here

3. Move the unzipped folder to the mongodb directory in /usr/local/

mv mongodb-linux-x86_64-3.2.12 /usr/local/mongodb

4. Configure system profile

sudo vi /etc/profile

Insert the following:

export MONGODB_HOME=/usr/local/mongodb export PATH=$PATH:$MONGODB_HOME/bin

Note: vi is the input command. When you see the page below, press the "i" arrow on the keyboard to enter the input mode, and then copy the above command. Then press esc to switch to command mode and enter: wq to save and exit


insert image description here

Note that you need to restart the system configuration after saving:

source /etc/profile

5. Create a folder for storing data and log files, and modify its permissions to add read and write permissions

cd /usr/local/mongodbsudo mkdir -p data/dbsudo chmod -r 777 data/dbsudo mkdir logscd logstouch mongodb.log 

insert image description here

6. Mongodb startup configuration

Go to the bin directory and add a configuration file:

cd /usr/local/mongodb/bin sudo vi mongodb.conf 

insert image description here

As mentioned above, the vi command is to write content. Enter i to enter the write mode. After writing, press esc to enter the command mode and enter :wq to save and exit.
Insert the following:

dbpath = /usr/local/mongodb/data/db 
#Data file storage directory logpath = /usr/local/mongodb/logs/mongodb.log 
#Log file storage directory port = 27017 
#Port fork = true 
#Enable as a daemon, i.e. run in the background nohttpinterface = true 

7. Start the mongod database service and start it with the configuration file

cd /usr/local/mongodb/bin./mongod -f mongodb.conf 

insert image description here

8. Connect to mongodb database

./mongo

Summarize

The above is the tutorial on installing mongodb under Linux introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • Installation and configuration tutorial of MongoDB under Linux
  • How to install MongoDB under Linux
  • MongoDB single node installation tutorial under Linux system
  • How to install PHP MongoDB extension on Linux server
  • Install PHP MongoDB driver on Linux
  • Steps and solutions for installing NoSQL (MongoDB and Redis) on Linux system (Summary)
  • Simple installation and basic operation of MongoDB under Linux system
  • Guide to installing MongoDB using command line (Windows, Linux)
  • Linux installation MongoDB startup and common problem solving

<<:  An article to quickly understand Angular and Ionic life cycle and hook functions

>>:  MySQL 5.7.19 winx64 free installation version configuration tutorial

Recommend

Detailed explanation of nginx proxy_cache cache configuration

Preface: Due to my work, I am involved in the fie...

Detailed use of Echarts in vue2 vue3

Table of contents 1. Installation 2. Use Echarts ...

Analyze MySQL replication and tuning principles and methods

1. Introduction MySQL comes with a replication so...

Example of using JS to determine whether an element is an array

Here are the types of data that can be verified l...

Detailed explanation of dynamic Christmas tree through JavaScript

Table of contents 1. Animated Christmas Tree Made...

Docker beginners' first exploration of common commands practice records

Before officially using Docker, let's first f...

React sample code to implement login form

As a Vue user, it's time to expand React. Fro...

Vue gets token to implement token login sample code

The idea of ​​using token for login verification ...

18 Web Usability Principles You Need to Know

You can have the best visual design skills in the...

Detailed process of FastAPI deployment on Docker

Docker Learning https://www.cnblogs.com/poloyy/p/...

Notes on matching MySql 8.0 and corresponding driver packages

MySql 8.0 corresponding driver package matching A...