Appearance
OSX MongoDB
使用 Homebrew 安装(推荐)
1. 添加 MongoDB 的 tap
bash
brew tap mongodb/brew2. 安装 MongoDB
bash
brew install mongodb-community3. 启动服务
bash
brew services start mongodb-community4. 验证
bash
mongosh常用 Homebrew 命令
bash
brew services stop mongodb-community # 停止
brew services restart mongodb-community # 重启
brew services list # 查看服务状态手动启动(不通过服务)
bash
mongod --config /opt/homebrew/etc/mongod.conf
# 或
mongod --dbpath /opt/homebrew/var/mongodb配置文件
Homebrew 安装的配置文件通常位于:
- Intel:
/usr/local/etc/mongod.conf - Apple Silicon:
/opt/homebrew/etc/mongod.conf
可在此修改端口、数据目录、日志路径等。下一节介绍 MongoDB Shell。