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自带截图命令ScreenCapture
macos
麦兜*1 天前
MongoDB Atlas 云数据库实战:从零搭建全球多节点集群
java·数据库·spring boot·mongodb·spring·spring cloud
麦兜*1 天前
MongoDB 在物联网(IoT)中的应用:海量时序数据处理方案
java·数据库·spring boot·物联网·mongodb·spring
TESmart碲视1 天前
Mac 真正多显示器支持:TESmart USB-C KVM(搭载 DisplayLink 技术)如何实现
macos·计算机外设·电脑
学编程的小程1 天前
突破局域网限制:MongoDB远程管理新体验
数据库·mongodb
清风6666662 天前
基于STM32的APP遥控视频水泵小车设计
stm32·单片机·mongodb·毕业设计·音视频·课程设计
2501_915106322 天前
Xcode 上传 ipa 全流程详解 App Store 上架流程、uni-app 生成 ipa 文件上传与审核指南
android·macos·ios·小程序·uni-app·iphone·xcode
他们都不看好你,偏偏你最不争气2 天前
【iOS】AFNetworking
开发语言·macos·ios·objective-c
最笨的羊羊2 天前
Debezium日常分享系列之:MongoDB 新文档状态提取
mongodb·debezium日常分享系列·新文档状态提取
王维志2 天前
LiteDB详解
数据库·后端·mongodb·sqlite·c#·json·database