MongoDb - Install MongoDb on Linux

Install MongoDb on Linux

Download

MongoDb installation packages are available for both 32 bit and 64 bit Linux. You can download it, and install.

Here is the link to download the installation packages of MongoDb : http://www.mongodb.org/downloads

mongodb download Linux

Unzip

After downloading the zip file, unzip it to the folder where you want to install.

Create a data directory

MongoDb stores data in db folder within data folder. But, since this data folder is not created automatically, you have to create it manually. Remember that data directory should be created in the root (/).

mongodb installation Linux

Run the MongoDb server from command prompt

To run MongoDb server from command prompt, you have to execute mongod.exe file from bin folder of mongodb folder.

mongodb run Linux command

Getting started with administrative shell

To start administrative shell, enter bin directory of your MongoDb installation and execute mongo.exe file. The default administrative shell of MongoDb is a JavaScript shell. When you connect mongodb immediately after installation, it connects to the test document (database).

run mongo shell

Since it is a JavaScript Shell, you can run some simple arithmetic operation.

db command will show you the list of documents(databases).

run mongo shell linux2

We will insert a simple record and retrieve the data now.

mongo first find linux

The first command inserts 8 to the z field, to the w3r collection(table).

MongoDb web interface

At a port number 1000 more than the port on which the MongoDb server is running, you can access a web interface of MongoDb.

If MongoDb is running at the default port 27017, the you can access the web interface at 28017.

mongodb web interface

 

 Source:http://www.w3resource.com/mongodb/installation-Linux.php