How to install MongoDB Community Edition on Ubuntu Server 18.04

MongoDB is one of the most popular NoSQL database management systems. It is known for it’s simplicity, wide adoption and high scalability. That is why in this article we’ll show you the basics of installing a Mongo server on your cloud machine.

Installing Mongo on Ubuntu has some prerequisites. The packages available in the Ubuntu repositories are very outdated. So you’ll first need to add the official MongoDB repositories.

Remember: the official u to date package is mongodb-org! Don’t install the default ‘mongodb’ package.

To add the repository execute the following two commands on your server:

sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv 9DA31620334BD75D9DCB49F368818C72E52529D4

echo “deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse” | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list

sudo apt-get update

This will add the official repository with the latest version of the packages and the repos key.

Once you’re ready you can install the mongodb-org package:

sudo apt-get install -y mongodb-org

When the installation is complete, you’ll have the latest version of MongoDB installed and ready for use. Now all you need to do is just start the service:

sudo service mongod start

To check that your Mongo server is up and running, you can take a look at the log file – “/var/log/mongodb/mongod.log”:

tail /var/log/mongodb/mongod.log

When you are ready, try connecting to your new Mongo server:

mongo –host 127.0.0.1:27017

Enjoy the power of MongoDB and come back to CloudBalkan Blog for more useful articles on MongoDB and NoSQL

Leave a Reply

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