Cannot connect to mongodb

So I've installed mongo using home brew and I've installed it through npm, so I have the JS driver.

When I run mongo in command line though, I get this -

 MongoDB shell version: 2.2.2
connecting to: test
Thu Jan 24 02:38:26 Error: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js:91
exception: connect failed

why is that happening?

After you've installed MongoDB, open a terminal window and go to the file path where your MongoDB application is stored e.g c:\MongoDB. Then type mongod and hit enter. This should start this process running. Mongod is the database server that you then access via the mongo shell.

After mongod is running, open a new terminal window and type mongo then hit enter. You should now be up and running. You can test that it's working by typing the following into the mongo shell as an example:

>
>db.names.save({'name':"James"})
>db.names.find()

This should then return the document you have just saved to the database as shown in the example below.

>{"_id" ObjectID:"764tdf763dyf6337fd376","name":"James"}

Read through the documentation and look for tutorials online. 10gen have just started an excellent online course. It's free and started this week so you might still be able to register.