Mac安装Mongodb

Homebrew 安装

  1. 更新 brew

brew update

  1. 添加 MongoDB 官方 tap

brew tap mongodb/brew

  1. 安装最新稳定版

brew install mongodb-community@7.0
(这里我写的是 7.0,如果你需要特定版本可以改,比如 6.0。)

  1. 启动 MongoDB 服务

brew services start mongodb-community@7.0
brew services start mongodb/brew/mongodb-community@7.0

  1. 确认 MongoDB 是否启动成功

ps aux | grep -v grep | grep mongod

  1. 连接 MongoDB

mongosh

默认会连到本地 mongodb://localhost:27017