This post is a quick how-to for installing MongoDB 3.6 on Ubuntu.
MongoDB is a free and open-source cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with schemas.
MongoDB 3.6 was released in November 2017, with a date for End-of-Life product support yet to be announced.
To install MongoDB 3.6, complete the following steps:
- Determine the MongoDB 3.6 repository to use based on the Ubuntu release codename, using the following commands:
codename=$(lsb_release -s -c) if [ $codename == "artful" ] || [ $codename == "bionic" ]; then codename="xenial"; fiThere is currently no specific MongoDB 3.6 repository for Ubuntu 17 Artful Aardvark or Ubuntu 18 LTS Bionic Beaver. However, these Ubuntu releases can use the MongoDB 3.6 repository for Ubuntu 16 LTS Xenial Xerus.
- Add the MongoDB 3.6 repository to the sources list, using the following command:
echo 'deb https://repo.mongodb.org/apt/ubuntu '$codename'/mongodb-org/3.6 multiverse' | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
- Import the MongoDB 3.6 repository public key, using the following command:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
- Update the package lists, using the following command:
sudo apt-get update
- Launch the MongoDB 3.6 installer, using the following command:
sudo apt-get install -y mongodb-orgThe download and installation process will begin and run through to completion with no further interaction required.
The remaining steps are optional, and will depend on your intended configuration.
- Allow the MongoDB service to start at boot, using the following command:
sudo systemctl enable mongod
- Start the MongoDB service, using the following command:
sudo systemctl start mongod
- Verify the MongoDB service is running, using the following command:
sudo systemctl status mongod
This command produces output similar to the following:
● mongod.service - High-performance, schema-free document-oriented database Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2018-06-13 12:00:05 UTC; 5s ago Docs: https://docs.mongodb.org/manual Main PID: 3069 (mongod) CGroup: /system.slice/mongod.service └─3069 /usr/bin/mongod --config /etc/mongod.conf Jun 13 12:00:05 ubuntu systemd: Started High-performance, schema-free document-oriented database.
MongoDB 3.6 is now installed and ready for use.