over 8 years ago
To my suprise, it is actually super easy to install MongoDB if you have brew installed:
brew install mongodb
Then, you have to set a path for MongoDB to store its data:
mkdir -p ~/data/db # <- create a folder at any location
mongod --dbpath ~/data/db # <- let mongodb know where you created the folder
mongod # <- run MongoDB server, use Ctrl + C to terminate it
To connect to the MongoDB server, open another terminal window:
mongo
That's it!
To import a JSON file into MongoDB:
mongoimport --db *database_name* --collection *collection_name* --type json --file *file.json*
For example:
mongoimport --db test --collection beijing --type json --file beijing_map.json