How To Install MongoDB on Linux

A database is a great and easy way to store information for your site or application. One of the most common database engines you may hear about is MySQL. While this is a common solution, and viable, some may choose to use MongoDB.

MongoDB is similar in that it provides an easy to use database. However, not only is the data stored differently, that data is also accessed in a different way. MongoDB mostly works through API calls. This allows MongoDB to easily be used with various programming languages for the database.

Here we’ll show you how to get MongoDB installed and setup on a Linux server. The installation steps may differ on the distribution of Linux you’re using, but should be fairly similar.

These guides will go through the steps on how to install MongoDB version 3.6. Though with other versions it’s a little similar.
 

How To Install MongoDB on CentOS

The steps to install MongoDB on CentOS are quite similar to those of Fedora and other RHELinux operating systems. For that, you’ll want to follow these steps.

  1. Login to your server using SSH.
  2. Once logged in, you’ll want to add the most recent repository for MongoDB so that Linux knows where to install MongoDB from. To do this you’ll want to navigate to the /etc/yum.repos.d/  folder. You can do that with the cd  command like this,
  3. This will bring you to the repositories directory. In here you’ll want to create a file called mongodb-org-3.6.repo and input some specific contents. To edit the file, you can do this with the nano  command or by using your favorite text editor.
  4. After you have brought the new file open for editing, you’ll want to type in the following:
  5. Once that is all typed out, you can close the file and save the changes by pressing Control + X  then entering Y . This will bring you back to the command line (out of the text editor).
  6. Now you are ready to install MongoDB. We will use the yum  command for this, like so:
  7. Entering the above command will start the installation process, which can take a few minutes. Though once completed, MongoDB will be ready to use. To start the server, you would just type:

 

How To Install MongoDB on Debian

  1. Login to your server via SSH.
  2. After you have successfully logged in, like the above steps for CentOS, you’ll want to add the repository to the package manager. To do this, it’ll require an additional step. Start by running this command here:
  3. The package manager that we will be using to install MongoDB, apt , requires that packages are signed with GPG keys. That command imports the MongoDB public GPG key for us to use. Now you’ll want to add the repository for MongoDB to the package manager. This will usually depend on the version of Debian that you use.
    • Debian 7: 
    • Debian 8:
  4. After executing the proper command for the version that you have, you’ll want to update the local package database. Luckily this command is not as long or complicated. This can be done by typing:
  5. Once that is done and has completed it’s execution, you’ll install MongoDB. Very similar to how it’s done in CentOS, you can do this by typing the command:
  6. This can take a little bit of time to run and install the required dependencies. But once it has finished, you are now able to start using MongoDB on your server! To start the MongoDB server, you can do so by typing this last command:

By default, some MongoDB installations will not have Authentication enabled. You can do this by modifying the security: authorization: field to be enabled.

If you should have any questions or would like assistance, do feel free to contact us through Live Chat, on our Phones, or by submitting a ticket with our Technical Support team.

Related Links

Related Articles


Share:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.