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> 
相关推荐
安然无虞8 小时前
「MongoDB数据库」初见
数据库·mysql·mongodb
深蓝电商API16 小时前
异步爬虫结合 MongoDB 异步驱动 pymongo:高效数据爬取与存储实践
爬虫·python·mongodb
chao_78917 小时前
双设备全栈开发最佳实践[mac系统]
git·python·macos·docker·vue·全栈
2501_9159214318 小时前
不用 Xcode 上架 iOS,拆分流程多工具协作完成 iOS 应用的发布准备与提交流程
android·macos·ios·小程序·uni-app·iphone·xcode
Ron丶18 小时前
iOS 旧版本 App 下载方法汇总:如何获取历史版本 IPA(2026 仍有效)
windows·经验分享·macos·ios·电脑
编程小风筝18 小时前
MAC物理地址和IP网络地址有什么区别?
网络协议·tcp/ip·macos
范纹杉想快点毕业18 小时前
STM32单片机与ZYNQ PS端 中断+状态机+FIFO 综合应用实战文档(初学者版)
linux·数据结构·数据库·算法·mongodb
雪域迷影1 天前
MacOS中运行Next.js项目注册新用户时MongoDB报错MongoServerError
mongodb·macos·react·next.js
AC赳赳老秦1 天前
DeepSeek 辅助科研项目申报:可行性报告与经费预算框架的智能化撰写指南
数据库·人工智能·科技·mongodb·ui·rabbitmq·deepseek
一心赚狗粮的宇叔2 天前
mongosDb 安装及Mongosshell常见命令
数据库·mongodb·oracle·nosql·web·全栈