MacOS 安装 MongoDB
博主目前都用 mac 电脑练习,所以这里重点讲 MacOS 安装方式
系统要求
MongoDB 4.4 社区版支持 macOS 10.13 或更高版本
安装 Homebrew
Homebrew 是一个软件包管理器。它的作用就是将软件包安装到自己的目录中,然后将其文件符号链接到 /usr/local。更多信息,请自行进入官网查看
https://brew.sh/
在将下面代码复制进终端
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
安装社区版的 MongoDB
下载 MongoDB 和数据库工具
brew tap mongodb/brew
安装 MongoDB
brew install mongodb-community@4.4 ==> Installing mongodb-community@4.4 from mongodb/brew ==> Downloading https:fastdl.mongodb.org/osx/mongodb-macos-x86_64-4.4.5.tgz Already downloaded: /Users/polo/Library/Caches/Homebrew/downloads/f86017008241ff604c5586f09b0ac27416ca9006d72f3c7087a9c8d02d26df8e--mongodb-macos-x86_64-4.4.5.tgz ==> Caveats mongodb-community@4.4 is keg-only,which means it was not symlinked into /usr/local,because this is an alternate version of another formula. If you need to have mongodb-community@4.4 first in your PATH,run: echo 'export PATH="/usr/local/opt/mongodb-community@4.4/bin:$PATH"' >> ~/.zshrc To have launchd start mongodb/brew/mongodb-community@4.4 now and restart at login: brew services start mongodb/brew/mongodb-community@4.4 Or,if you dont want/need a background service you can just run: mongod --config /usr/local/etc/mongod.conf ==> Summary