Objective
The objective is to install MongoDB on Ubuntu 18.04 Bionic Beaver LinuxOperating System and Software Versions
- Operating System: - Ubuntu 18.04 Bionic Beaver
- Software: - MongoDB 3.6 or higher
Requirements
Privileged access to your Ubuntu System as root or viasudo
command is required. Difficulty
EASYConventions
- # - requires given linux commands to be executed with root privileges either directly as a root user or by use of
sudo
command - $ - requires given linux commands to be executed as a regular non-privileged user
Instructions
Add MongoDB repository
First head over to the official MongoDB download page and take a note of the latest MongoDB version.Note: At the time of writing there is currently no official release for Ubuntu 18.04 Bionic. From this reason we will be using Xenial version instead.
Open up terminal and enter the following linux commands while changing your desired mongoDB version and Ubuntu release codename:
$ codename=xenial $ mongodb=3.6
Once the above variables are set, simply enter the below command to import MongoDB release signing key:
$ wget -qO- https://www.mongodb.org/static/pgp/server-${mongodb}.asc | sudo apt-key add
Next, add the repository:
$ sudo bash -c "echo deb http://repo.mongodb.org/apt/ubuntu ${codename}/mongodb-org/$mongodb multiverse > /etc/apt/sources.list.d/mongodb-org.list"
update the repository index:
$ sudo apt update
Install MongoDB
Use the following linux command to install MongoDB on Ubuntu 18.04 Bionic server:$ sudo apt-get install -y mongodb-org
Start MongoDB Database
After installation the MongoDB database does not start by default. To start the database enter:$ sudo service mongod start