Official website tutorial https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/
Using third-party BREW Package Penalty for Manager install MongoDB 4.2 Community Edition on macOS.
MongoDB 4.2 Community Edition, support macOS version 10.12 or higher.
installation
1, the Homebrew installation, refer https://brew.sh/#install
2, run BREW TAP MongoDB / BREW , may need to wait a few minutes
3, run BREW install MongoDB-Community Community @ 4.2 install Community Edition 4.2 @
This step is in addition to the installation binary file, add the following files will
At this point run mongod -version will print out the installed version proved successful installation.
MongoDB service started
Use brew the MongoDB service running as macOS
# 启动 brew services start mongodb-community # 停止 brew services stop mongodb-community
MongoDB can use the following command to view the running service
ps aux | grep -v grep | grip mongod
Connect and use MongoDB
First start MongoDB service.
Run mongo connection service, you can see a successful connection mongo service.
$ mongo MongoDB shell version v4.2.3 connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb