Friday, April 17, 2020

How to Install MongoDB on Ubuntu 18.04 & 16.04

Hello,
We all know that MongoDB is the database for modern applications, to give a definition of MongoDB we can say that MongoDB is a distributed, universal, document-based database that was designed for modern application developers and for the cloud age. No other database offers such productivity.



MongoDB allows you to manipulate structured objects in BSON format (binary JSON), without a predetermined scheme. In other words, keys can be added at any time "on the fly", without reconfiguring the database.
This tutorial will help you to install MongoDB  on Ubuntu 18.04 and 16.04.

to properly install MongoDB just follow the following steps :
  • Import the MongoDB repository

You must use the following command will import the MongoDB public GPG key.
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
After that you will need to Create the /etc/apt/sources.list.d/mongodb-org-3.4.list, it's a source list file for MongoDB, to do that you need only to run the next command :
echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
  • Install MongoDB 

Now we have added the APT repository, there are just the commands to install MongoDB directly on our linux machine.
First of all you need to update your local package repository by using the following command :
sudo apt-get update

And after that you can Install the latest stable version of MongoDB with this command :
sudo apt-get install -y mongodb-org
After installation, MongoDB will start automatically. but you can use the next commands to start and stop MongoDB.

sudo systemctl enable mongod
sudo systemctl start mongod

you can also use following commands to stop or restart MongoDB service.
sudo systemctl stop mongod
sudo systemctl restart mongod


0 comments:

Post a Comment