How to install the NoSQL database server MongoDB on Linux

How to install the NoSQL database server MongoDB on Linux

MongoDB has been around since 2009 and has recently picked up steam as an open-source alternative to other popular NoSQL databases like Cassandra and HBase. MongoDB stores all of its data in documents and stores these documents in collections, which are similar to tables in relational databases like MySQL. One of the things that makes MongoDB so popular is how easy it is to install on Linux servers, so this tutorial will show you how to install MongoDB on your own Linux server. Let’s get started!

Step 1) Download MongoDB

If you want to download and install MongoDB, visit their website and click the Downloads tab. From there, you can choose your preferred flavor of installation. For example, if you are using a 64-bit version of Ubuntu 12.04 LTS then download the Ubuntu (x86_64) package. Next, extract the archive file with tar zxvf

Step 2) Install MongoDB

  • The first step is to download and extract the tar.gz archive. I recommend extracting it in your home directory by running:
  • sudo tar xzf mongodb-linux-x86_64-2.6.3.tgz && sudo mkdir -p /data/db && sudo chown -R $USER:$USER /data/db/.
  • If you want to be able, you can change the owner of the directory and its contents so that you are both able to write data and read data from this directory.

Step 3) Run your first SQL query

You can now try your first SQL query by using the following:

  1. Connecting to your mongodb server with a command prompt. Type mongo in a new command prompt window and hit enter. You should now see some text from the mongo shell like this:

 Step 4) Use Mongo as an application

Mongo is a very popular open-source, document-oriented database. It can be installed and run as an application with a single command. When you first download it, it will prompt you for what type of installation you want (development or production) and how much space in MBs to allocate for storage. You can get started with a basic installation by running the following command