Install MongoDB on Ubuntu

MongoDB is an open-source document database, and the leading NoSQL database. Written in C++.

This example is using MongoDB 2.4.6, running on Ubuntu13.4, both MongoDB client and server console are run on localhost, same machine.

  • Download MongoDB from here.
  • Enter into the directory where the MongoDB is downloaded. By default it downloads in “Downloads” directory
$ cd Downloads/
  • Unzip the tar file.
$ tar xzf mongodb-linux-i686-2.4.6.tgz
  • Move mongodb-linux-i686-2.4.6 to mongodb
$ sudo mkdir /usr/lib/mongodb

$ sudo mv mongodb-linux-i686-2.4.6 /usr/lib/mongodb/

  • Before you start mongod for the first time, you will need to create the data directory. By default, mongod writes data to the /data/db/ directory. To create this directory, and set the appropriate permissions use the following commands:
# mkdir -p /data/db

# chmod 777 /data/*

1st command prompt: Start mongodb server

$ cd /usr/lib/mongodb/mongodb-linux-i686-2.4.6/bin/

$ ./mongod


2nd command prompt: Start the client

$ cd /usr/lib/mongodb/mongodb-linux-i686-2.4.6/bin/

$ ./mongo




Note: The information provided here is best of my knowledge and experiences if at all any modifications are to be made please help me with your valuable suggestions which are always welcome…. :)