How to Install MongoDB on Ubuntu 18.04 Bionic Beaver

Install MongoDB on Ubuntu 18.04

In this article, we will have explained the necessary steps to install and configure MongoDB on Ubuntu 18.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

MongoDB is a free, distributed, and an open-source document database at its core that powers high availability, horizontal scaling, and geographic distribution. It stores data in JSON-like documents and supports Ad hoc queries, indexing, and real-time aggregation.

Install MongoDB on Ubuntu

Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.

Step 2. Install MongoDB on Ubuntu 18.04.

Now, add the MongoDB GPG key to your system using the following command:

Use the following linux command to install MongoDB on Ubuntu 18.04 Bionic server:

Once the installation is completed, start the MongoDB daemon and enable it to start on boot by typing:

Step 3. Enable Remote MongoDB Access on Firewall.

By default MongoDB runs on port 27017, to allow access from everywhere you can use:

To allow remote MongoDB connections, you need to add your server IP address to /etc/mongodb.conf configuration file as shown:

Save the file, exit the editor, and restart MongoDB:

That’s all you need to do to install MongoDB on Ubuntu 18.04. I hope you find this quick tip helpful. If you have questions or suggestions, feel free to leave a comment below.