How to install MongoDB on Ubuntu 16.04

To ensure the credibility of the packages Ubuntu makes sure they are signed with GPG keys.
Let’s begin by importing the GPG keys we need for the official MongoDB repository:

Next add the MongoDB repository in /etc/apt/sources.list.d using this command:

Installing MongoDB

Create service file for MongoDB

Paste following code:

Now we have to update systemd to include our newly created service and we enable and start the service:

Create admin user in MongoDB:

Enable MongoDB authentication

Open file /etc/systemd/system/mongodb.service and update following line:

After that reload configurations:

Now connect to the MongoDB shell using this command:

Leave a Reply

Your email address will not be published. Required fields are marked *