Begin by going to https://www.mongodb.com/download-center?jmp=nav and grabbing the latest 64-bit version of MongoDB.

You should get a package with a name something like mongodb-osx-x86_64-1.2.3.tgz.

Next, you can untar that file wherever you like. If this is your first time, it’s probably easiest to just untar it in the area where you normally work on code.

$ tar -zxvf  mongodb-osx-x86_64-1.2.3.tgz

When you are done with this command, you should have a directory called mongodb-osx-x86_64-1.2.3. It's contents will look something like this

$ ls -1
GNU-AGPL-3.0
README
THIRD-PARTY-NOTICES
bin
include
lib

The two parts of MongoDB that we are immediately concerned with are in bin, and they are mongod (the server) and mongo (the CLI client).

Before you can start MongoDB, you need to create a location for it to store databases. By default, it stores them in /data/db. You can create that with a simple command:

$ mkdir -p /data/db

Make sure that the OS X user that will run the server has write access to /data/db.

Now all you need to do is start the mongod server.

./bin/mongod &

It should now be running. You can test your new database using the mongo command line client. Here's an example:

$ ./mongo

Now you can see the mongo cli client running & accepting mongo commands 

Let's see what databases are created by default:
> show dbs
admin
local
test

You are done with mongoDB setup in your OSX / Unix . 


How to install MongoDB ?
Tagged on:                 

Leave a Reply

Your email address will not be published. Required fields are marked *