Database

How to Install MongoDB Server on Ubuntu and Debian Based System

MongoDB is an free and open source database which uses a document-oriented data model. MongoDB is a NoSQL database. It provides large media storage with GridFS. To know about MongoDB click here.

In this article I will show how you can install MongoDB server on Ubuntu and Debian based system.

Follow the below steps to install MongoDB server Ubuntu and Debian based system.

Step #1 : Setup APT Repository

First of all, you have to import MongoDB public GPG key in your system using below command. This will ensure package consistency and authenticity.

$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6

Now add MongoDB APT repository url editing /etc/apt/sources.list.d/mongodb-3.4.list.

$ echo "deb http://repo.mongodb.org/apt/debian "$(lsb_release -sc)"/mongodb-org/3.4 main" | sudo tee /etc/apt/sources.list.d/mongodb-3.4.list

Step #2 : MongoDB Server Installation

Once adding apt repository on your system now install MongoDB server. Follow the below command to install MongoDB server.

$ sudo apt-get update
$ sudo apt-get install mongodb-org

You can also define mongodb version if you want to install as shown below.

$ sudo apt-get install mongodb-org=3.4.10 mongodb-org-server=3.4.10 mongodb-org-shell=3.4.10 mongodb-org-mongos=3.4.10 mongodb-org-tools=3.4.10

Step #3 : Start MongoDB Service

After installing MongoDB server use the below command to start it. Follow the below command to start and stop MongoDB service.

$ sudo service mongod start
$ sudo service mongod stop

Step #4 : Check MongoDB Version

Follow the below command to check the installed MongoDB version on your system.

$ mongod --version 

db version v3.4.9
git version: 876ebee8c7dd0e2d992f36a848ff4dc50ee6603e
OpenSSL version: OpenSSL 1.0.1u-fips  22 Sep 2016
allocator: tcmalloc
modules: none
build environment:
    distmod: ubuntu1604
    distarch: x86_64
    target_arch: x86_64

Congratulation! MongoDB has been successfully installed on your system.

Thank you! for visiting LookLinux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.

About the author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Leave a Comment