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

Perfect solution to MySQL common insufficient memory startup failure

1. If MySQL is not started successfully, check th...

Build a severe weather real-time warning system with Node.JS

Table of contents Preface: Step 1: Find the free ...

Understand the principles of MySQL persistence and rollback in one article

Table of contents redo log Why do we need to upda...

Use of Vue3 pages, menus, and routes

Table of contents 1. Click on the menu to jump 1....

Methods and techniques for designing an interesting website (picture)

Have you ever encountered a situation where we hav...

MySQL 8.0.19 installation and configuration tutorial under Windows 10

I will be learning MySQL next semester. I didn...

Problems and solutions when replacing Oracle with MySQL

Table of contents Migration Tools Application tra...

You may not know these things about Mysql auto-increment id

Introduction: When using MySQL to create a table,...

CSS implements a pop-up window effect with a mask layer that can be closed

Pop-up windows are often used in actual developme...

Learn to deploy microservices with docker in ten minutes

Since its release in 2013, Docker has been widely...

Two ways to remove the 30-second ad code from Youku video

I believe everyone has had this feeling: watching ...

How to Install Oracle Java 14 on Ubuntu Linux

Recently, Oracle announced the public availabilit...