Installing MongoDB in Ubuntu is pretty easy. The following steps will guide you on how to install and run the mongodb server.

Step #1:
Download MongoDB to your Ubuntu box. Check the version from Let download the latest 64bit production release (currently, 2.4.6).

$ wget

Step #2:
Run the following command to extract the tgz file.

$ tar -zxvf mongodb-linux-x86_64-2.4.6.tgz

Step #3:
You are almost done with this tutorial. Let’s create a directory to hold all your mongodb data. You will instruct mongodb to store all your data here . We will start the mongodb server after we have created the data/db directory.

$ mkdir -p data/db
$ cd mongodb-linux-x86_64-2.4.6/bin
$ ./mongod --dbpath ~/data/db
By now, your mongodb engine should be started and waiting for connection on certain port as following
$ Fri Sep 27 17:13:05.116 [initandlisten] waiting for connections on port 27017
$ Fri Sep 27 17:13:05.117 [websvr] admin web console waiting for connection on port 28017

Step #4:
Connect to your mongdb is easy by using of mongo shell. Make sure you are at the correct directory.

$ cd mongodb-linux-x86_64-2.4.6/bin
$ ./mongo
MongoDB shell version: 2.4.6
connecting to: