This post talks about installing and configuring MongoDB.
Go to http://www.mongodb.org/downloads and refer the production release section. Go to corresponding operating system, in this case OS X and click on download. Prefer 64 bit version.
Decompress the downloaded file. Rename the folder as mongodb. You will get a bin directory and few other files. In bin directory there are two files which we will use most frequently, called "mongo" and "mongod". The "mongo" executable will be used to start interactive mongo shell and "mongod" will be used to start mongodb server.
If you click on mongodb to start server you might get this error, "error :dbpath (/data/db/) does not exist". Lets see how we can fix this.
We get the error as it can not find folder /data/db as mentioned in dbpath. So we can either change the dbpath or create those folders by following commands.
> sudo mkdir /data
> sudo mkdir /data/db
> sudo chmod 777 /data/db
We use sudo as we are trying to create directory at root level. By using chmod we are making sure that directory is available to read, write and execute.
Start the server
Now you can click on "mongod" or run "./mongod" from command line in bin folder to start mongodb server. The port 27017 will be used to start this service. You will get notification and lot of status messages in terminal when the server starts. You can leave this terminal window as it is and use another window for performing your terminal dependent tasks.
To cross check that you have started the server, enter this url in broswer "http://localhost:28017/". You should be able to see something similar to following.
We will discuss about database creation, loading and querying data in next post.