Hello Folks, Today in this quick tutorial I am going to tell you how you can install MongoDB 3.6 on your Ubuntu system. Before this Let me tell you MongoDB is a NoSQL database and also one of the famous latest in the database family.

“MongoDB is a document database with the scalability and flexibility that you want with the querying and indexing that you need” MongoDB Official website

Here are some few feature listing for MongoDB Database.1

— Free and open source database
— Stores data in flexible, JSON-like documents
— maps to the objects in your application code.
— Ad hoc queries, indexing, and real-time aggregation provide powerful ways to access and analyze your data
— high availability, horizontal scaling, and geographic distribution are built in and easy to use

Here are the few of steps by you can Install MongoDB 3.6 on your Ubuntu system.

#1: First, you need to Import the Public Key :

Simply open the Command terminal and type this command and hit enter.


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

#2:- Now, after this you need to Create source list file for MongoDB. You can create in path /etc/apt/sources.list.d/mongodb-org-3.6.list with this command:


$ echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list


#3:- Update the repository Packages with the following command.


$ sudo apt-get update

#4: Now, Install the MongoDB

Just write the following command on your terminal.


$ sudo apt-get install -y mongodb-org

If you want to install the specific release of mongoDB then you can write command also.


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

Pin a specific version of MongoDB.

To pin the version of MongoDB at the currently installed version, issue the following command sequence:


echo "mongodb-org hold" | sudo dpkg --set-selections
echo "mongodb-org-server hold" | sudo dpkg --set-selections
echo "mongodb-org-shell hold" | sudo dpkg --set-selections
echo "mongodb-org-mongos hold" | sudo dpkg --set-selections
echo "mongodb-org-tools hold" | sudo dpkg --set-selections


#5:- Start MongoDB with the following command.


$ sudo service mongod start

#6:- Stop MongoDB with the following command.


$ sudo service mongod stop

#7:-Restart MongoDB with the following command.

 

$ sudo service mongod restart




<h1>If you want to remove packages for mongoDB that you have previously installed on your ubuntu system.</h1>

so you can just write the following command.



$ sudo apt-get purge mongodb-org*

Also if you want to Remove Data Directories then you can write the following command.


$ sudo rm -r /var/log/mongodb

$ sudo rm -r /var/lib/mongodb

If you want to download the latest version of MongoDB so you can download it from here.

Download center of MongoDB

Krishna Gupta

Krishna Ballabh Gupta is a Gold Medalist Full Stack Developer & Algorithm Designer and Founder of TechnologyShouters. He generally Blogs about Python, JavaScript, jQuery, AngularJS, Database, PHP, AJAX and something that interesting.

Related Posts

Create Account



Log In Your Account



1Subscribe to Our Live Updates.