mac安装mongoDB的正确姿势

bash 复制代码
testmanzhang@TestMandeMBP corpora % brew tap mongodb/brew
bash 复制代码
testmanzhang@TestMandeMBP corpora % brew search mongodb
bash 复制代码
testmanzhang@TestMandeMBP corpora % brew install mongodb-community@7.0

依次执行上面的命令后开始安装mongoDB,但是安装过程中有很多报错,例如:

bash 复制代码
Error: openjdk: Failed to download resource "openjdk"
...
Error: pango: Failed to download resource "pango"
...
Error: ffmpeg@6: Failed to download resource "aom"
...
Error: ffmpeg: Failed to download resource "x265"
...
Error: gtk4: Failed to download resource "gtk4"
...
Error: libsoup: Failed to download resource "sqlite"
...
Error: python@3.13: Failed to download resource "python@3.13"
...
Error: gstreamer: Failed to download resource "ffmpeg"
...
Error: allure: Failed to download resource "openjdk"
...
Error: qt: Failed to download resource "qt"
...
Error: pyqt: Failed to download resource "qt"
...
Error: vtk: Failed to download resource "python@3.13"
...
Error: opencv: Failed to download resource "openvino"
...

报错有点多,可能是姿势不对,一个一个解决有点麻烦,可能有的跟mongoDB也没有关系,但是强迫症,看着不舒服,重装!

先卸载mongoDB:

bash 复制代码
testmanzhang@TestMandeMBP corpora % brew uninstall mongodb-community@7.0
bash 复制代码
testmanzhang@TestMandeMBP corpora % brew uninstall mongodb-database-tools

清除homebrew缓存:

bash 复制代码
testmanzhang@TestMandeMBP corpora % brew cleanup

删除mongoDB的残存文件:

bash 复制代码
testmanzhang@TestMandeMBP corpora % rm -rf /usr/local/var/mongodb
testmanzhang@TestMandeMBP corpora % rm -rf /opt/homebrew/var/mongodb

先更新一下homebrew:

bash 复制代码
testmanzhang@TestMandeMBP corpora % brew update

重新安装mongoDB:

bash 复制代码
testmanzhang@TestMandeMBP corpora % brew tap mongodb/brew
bash 复制代码
testmanzhang@TestMandeMBP corpora % brew install mongodb-community@7.0

这回安装比较顺利,没有报错!!!

启动mongoDB:

bash 复制代码
testmanzhang@TestMandeMBP corpora % brew services start mongodb/brew/mongodb-community@7.0
==> Successfully started `mongodb-community@7.0` (label: homebrew.mxcl.mongodb-community@7.0)

关闭mongoDB:

bash 复制代码
testmanzhang@TestMandeMBP corpora % brew services stop mongodb/brew/mongodb-community@7.0
Stopping `mongodb-community@7.0`... (might take a while)
==> Successfully stopped `mongodb-community@7.0` (label: homebrew.mxcl.mongodb-community@7.0)

连接mongoDB:

bash 复制代码
mongosh
bash 复制代码
testmanzhang@TestMandeMBP ~ % mongosh   
Current Mongosh Log ID:	67e2a00939223a773679ef31
Connecting to:		mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.4.2
Using MongoDB:		7.0.17
Using Mongosh:		2.4.2

For mongosh info see: https://www.mongodb.com/docs/mongodb-shell/

------
   The server generated these startup warnings when booting
   2025-03-25T20:22:23.392+08:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
------

test> 
相关推荐
肖永威1 小时前
macOS环境安装/卸载python实践笔记
笔记·python·macos
雨中风华6 小时前
Linux, macOS系统实现远程目录访问(等同于windows平台xFsRedir软件的目录重定向)
linux·windows·macos
码界调试侠8 小时前
MongoDB 常用查询语法
数据库·mongodb
爬山算法9 小时前
MongoDB(1)什么是MongoDB?
数据库·mongodb
有趣的杰克10 小时前
开源|macOS 菜单栏 AI 启动器 GroAsk:⌥Space 一键直达 ChatGPT / Claude / Gemini
人工智能·macos·chatgpt
疯狂敲代码的老刘10 小时前
JDK 1.6到25 全版本网盘合集 (Windows + Mac + Linux)
java·linux·windows·macos·jdk
范纹杉想快点毕业11 小时前
从单片机基础到程序框架:构建嵌入式系统的完整路径
数据库·mongodb
jxy999812 小时前
mac mini 安装java JDK 17
java·开发语言·macos
范纹杉想快点毕业12 小时前
从单片机基础到程序框架:全方位技术深度解析
数据库·mongodb
Figo_Cheung12 小时前
Figo关于OpenClaw(MacOS)安装前环境变量设置保姆级教程
macos·性能优化·个人开发