博主目前都用 mac 电脑练习,所以这里重点讲 MacOS 安装方式
MongoDB 4.4 社区版支持 macOS 10.13 或更高版本
Homebrew 是一个软件包管理器。它的作用就是将软件包安装到自己的目录中,然后将其文件符号链接到 /usr/local。更多信息,请自行进入官网查看
https://brew.sh/
在将下面代码复制进终端
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew tap mongodb/brew
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.tgzAlready 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.4Or, if you don't want/need a background service you can just run: mongod --config /usr/local/etc/mongod.conf==> Summary ???? /usr/local/Cellar/mongodb-community@4.4/4.4.5: 11 files, 157.3MB, built in 4 seconds
最新5.0,先不做小白鼠
echo 'export PATH="/usr/local/opt/mongodb-community@4.4/bin:$PATH"' >> ~/.zshrc source ~/.zshrc
mongo --version mongod --version # 均显示 db version v4.4.5Build Info: { "version": "4.4.5", "gitVersion": "ff5cb77101b052fa02da43b8538093486cf9b3f7", "modules": [], "allocator": "system", "environment": { "distarch": "x86_64", "target_arch": "x86_64" } }
brew services start mongodb-community@4.4
brew services stop mongodb-community@4.4
intel 处理器
mongod --config /usr/local/etc/mongod.conf --fork
M1 处理器
mongod --config /opt/homebrew/etc/mongod.conf --fork
从 mongo shell 连接到 mongod,并发出关闭命令
brew services list
ps aux | grep mongdbps aux | grep -v grep | grep mongod
mongo
brew services list 查看 MongoDB 服务 status 显示 error 的问题
https://www.cnblogs.com/poloyy/p/14828075.html
执行 mongo、mongod 显示无命令
https://www.cnblogs.com/poloyy/p/14828089.html
https://docs.mongodb.com/v4.4/tutorial/install-mongodb-on-windows/
https://docs.mongodb.com/v4.4/administration/install-on-linux/