Step 1: Install Mongo DB
brew install mongodb
When mongodb is installed using homebrew. Please make a note of default paths,
- The databases are stored in the /usr/local/var/mongodb/ directory
- The mongod.conf file is here: /usr/local/etc/mongod.conf
- The mongo logs can be found at /usr/local/var/log/mongodb/
- The mongo binaries are here: /usr/local/Cellar/mongodb//bin
Source: http://stackoverflow.com/questions/13827915/location-of-the-mongodb-database-on-mac
Step 2: Run MongoDB Server (while starting mongodb server specify path to data directory - where we want our databases to get stored)
mongod --dbpath /usr/local/var/mongodb/
We are using above path because, when we install mongo using brew, it creates folder /usr/local/var/mongodb/ for storing databases. Otherwise we can also use someother path for data directory
Step 3: Run Mongo Shell (mongo-db console)
To run mongo shell, keep mongod server running, that you have started in step 2. Now, create open new terminal & start mongo shell (from here you can create / modify databases)
mongo
That's it, you just have to use above command for getting into mongo shell.
Source: http://stackoverflow.com/questions/18452023/installing-and-running-mongodb-on-osx