This is just a pointer blog to the mongoDB documentation and a basic guide to getting started with using MongoDB on the local system and playing around with it.
Lets first install MongoDB on the Mac and then make a sample app using it.
1.) Installation :
We can use brew to install mongoDB on the mac. Installation instructions can be found here.
Anirudhs-MacBook-Pro:~ anirudh$ brew install mongodb
By default mongodb uses the folder /data/db for the database, so make sure that the directory exists and has all the permissions required.
Once db folder is set, we can run mongodb by the command :
Anirudhs-MacBook-Pro:~ anirudh$ mongod
This will start the mongodb server listening at port 27017.
Once the server is up, we can open a mongo shell to perform the db operations just like using a mysql client.
Login to mongo shell
Anirudhs-MacBook-Pro:~ anirudh$ mongo MongoDB shell version: 2.6.3 connecting to: test Welcome to the MongoDB shell.
We can use the help command to see all the operations like create databases, indexes, insert rows, etc.
Lets see few basic examples which can be helpful for our stint with mongo:
To display the database we are using:
To use the database
To view all the collections in the db
More details of getting started are well documented at the mongodb site here.
In the next blog we will make a spring application talk to mongo DB.