Homebrew 安装
- 更新 brew
brew update
- 添加 MongoDB 官方 tap
brew tap mongodb/brew
- 安装最新稳定版
brew install mongodb-community@7.0
(这里我写的是 7.0,如果你需要特定版本可以改,比如 6.0。)
- 启动 MongoDB 服务
brew services start mongodb-community@7.0
brew services start mongodb/brew/mongodb-community@7.0
- 确认 MongoDB 是否启动成功
ps aux | grep -v grep | grep mongod
- 连接 MongoDB
mongosh
默认会连到本地 mongodb://localhost:27017