安裝
1. Update Homebrew’s package database.
brew update
2. Install MongoDB
brew install mongodb
3. Install the MongoDB Binaries with TLS/SSL Support
brew install mongodb --with-openssl
4. Install the Latest Development Release of MongoDB
brew install mongodb --devel
運(yùn)行
1. Create the data directory
mkdir -p /data/db
2. Set permissions for the data directory
Before running?mongod?for the first time, ensure that the user account running?mongod?has read and write permissions for the directory.
3. Run MongoDB
mongod
Specify the path of the data directory
If you do not use the default data directory (i.e.,/data/db), specify the path to the data directory using the--dbpath option
mongod --dbpath? <path to data directory>
參見(jiàn): https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/