Table of contents
Prerequisites Homebrew
check homebrew
installed skip
Check whether the homebrew command is installed, if not installed, install this first
brew --version
install homebrew
Check out another blog post macos install Homebrew
Install mongoDB
Official website address: https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-os-x/
installation process
1. Download the official Homebrew formula for MongoDB and database tools
brew tap mongodb/brew
2. To update Homebrew and all existing formulas: to prevent accidents from failing to install
brew update
3. Installation
brew install [email protected]
4. Check whether the installation is successful
mongod --version
General default file storage location:
start method
Two startup methods:
1. Start/shutdown as a macos service
# 启动
brew services start [email protected]
# 关闭
brew services stop [email protected]
2. Start as a background process, here is the m1 chip
# m1 芯片
mongod --config /usr/local/etc/mongod.conf --fork
# Intel 芯片
mongod --config /opt/homebrew/etc/mongod.conf --fork
Note: The way to close the background process is to directly use the shutdown or exit command of mongosh
common problem
If you encounter ChecksumMismatchError
errors, check here: Troubleshooting ChecksumMismatchError
Error: An exception occurred within a child process:
ChecksumMismatchError: SHA256 mismatch
Expected: c7214ee7bda3cf9566e8776a8978706d9827c1b09017e17b66a5a4e0c0731e1f
Actual: 6aa2e0c348e8abeec7931dced1f85d4bb161ef209c6af317fe530ea11bbac8f0
Archive: /Users/kay/Library/Caches/Homebrew/downloads/a6696157a9852f392ec6323b4bb697b86312f0c345d390111bd51bb1cbd7e219--mongodb-macos-x86_64-4.2.0.tgz
To retry an incomplete download, remove the file above.
To put it bluntly, it is in conflict with the previous version. The actual version is not the same as expected. Delete the previous version and download the current one.
1. Delete the downloaded .tgz
document and find out where the download is
2. Re-download a new formula
brew untap mongodb/brew && brew tap mongodb/brew
3. Try to install again
brew install [email protected]