MongoDB ..Let’s get it started

MongoDB is a document database and I won’t bore you with details about what it can do. MongoDB makes many claims, they are
here. In short, MongoDB is a document database that stores data in a JSON format and then promises to make out lives easier. Download Installation instruction are varied depending on your OS etc..and the both varieties of bitness are also available.

The shell for MongoDB is a Javascript based one, so if you know a bit of JS then you will fly in there. Start mongod from the command line, this can be done by navigating to the bin directory of installation. Provide the dbpath(the place where it stores the data) as well.


If you look at the output when we start the daemon (mongod = mongo-daemon) then the last line talks about a rest interface. This can be enable by passing the –rest flag when starting the instance. The port for viewing the webpage is also there.

Let’s get into the mix of things by connecting to this mongod using the shell(mongo.exe). Navigate to the mongo directory and go mongo.exe.
By default this connects to the test database. The prompt will say something like

MongoDB shell version: 2.4.1
connecting to: test

At any moment you can go back to mongod and check how many connections are open. Run a couple of commands like
show dbs
show collections

to see if everything is in order.

Create a new database by use yourdatabasename. The shell will switch it’s context to that database(after creating it if it does not exist already.)
Next, time we will do some stuff by creating some collections and then querying. This will be a longish series, hold on and let me smear you twitter timelines.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s