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

MySQL8.0.18 configuration of multiple masters and one slave

Table of contents 1. Realistic Background 2. Agre...

Detailed tutorial on installing MySQL 8.0 from source code on CentOS 7.4

Table of contents 1. Environment 2. Preparation 3...

Specific use of CSS front-end page rendering optimization attribute will-change

Preface When scroll events such as scroll and res...

Html+css to achieve pure text and buttons with icons

This article summarizes the implementation method...

Summary of Common Commands for Getting Started with MySQL Database Basics

This article uses examples to describe the common...

CSS3 Tab animation example background switching dynamic effect

CSS 3 animation example - dynamic effect of Tab b...

Let's talk about the two functions of try catch in Javascript

The program is executed sequentially from top to ...

Code analysis of synchronous and asynchronous setState issues in React

React originated as an internal project at Facebo...

Detailed steps to download Tomcat and put it on Linux

If you have just come into contact with Linux, th...

How to use js to determine whether a file is utf-8 encoded

Conventional solution Use FileReader to read the ...

MySQL executes commands for external sql script files

Table of contents 1. Create a sql script file con...

Some wonderful uses of URL objects in JavaScript

Table of contents Preface Parsing parameters Modi...