簡體   English   中英

使用 Homebrew 安裝 MongoDB

[英]Installing MongoDB with Homebrew

我對 MongoDB 比較陌生,我正在嘗試使用 Homebrew 在我的 Mac 上安裝 MongoDB,但出現以下錯誤:

Error: No available formula with the name "mongodb" 
==> Searching for a previously deleted formula (in the last 
month)...
Warning: homebrew/core is shallow clone. To get complete history 
run:
  git -C "$(brew --repo homebrew/core)" fetch --unshallow

Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.

我跑了brew update然后brew install mongodb

公式mongodb已從 homebrew-core 中刪除。 從 homebrew-core 檢查pr-43770

致我們的用戶:如果您來到這里是因為 mongodb 停止為您工作,我們已將其從 Homebrew 核心公式中刪除,因為它已遷移到非開源許可證

幸運的是,mongodb 的團隊正在維護一個自定義的 Homebrew Tap。 您可以卸載舊的mongodb,然后從新的tap 重新安裝新的mongodb。

brew services stop mongodb
brew uninstall homebrew/core/mongodb

brew tap mongodb/brew
brew install mongodb-community
brew services start mongodb-community

檢查mongodb/homebrew-brew以獲取更多信息。

首先安裝mongodb

brew tap mongodb/brew

其次使用此命令安裝。 mangodb 安裝成功

brew install mongodb-community@4.0 

你會得到輸出

==> CaveatsTo have launchd start mongodb/brew/mongodb-community now and restart at login:
  brew services start mongodb/brew/mongodb-community
Or, 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.2.2: 21 files, 274.5MB, built in 2 minutes 46 seconds
brew services start mongodb/brew/mongodb-community
==> Successfully started `mongodb-community` (label: homebrew.mxcl.mongodb-commu

關於macOS Big SurHomebrew ,mongodb 文檔說明: https : //docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/

您應該安裝支持 macOS 10.13 或更高版本的 MongoDB 4.4 社區版,因此這些步驟會有所幫助。

解決方案 1:如果您之前安裝了舊版本的公式,您可能會遇到ChecksumMismatchError來解決這個問題:

刪除下載的 .tgz 存檔。

brew untap mongodb/brew && brew tap mongodb/brew

重新計算公式。

  brew install mongodb-community@4.4 

解決方案 2:如果您尚未安裝任何版本的公式。

1、從https://brew.sh/#install安裝Xcode命令行工具和Homebrew

xcode-select --install

2、點擊MongoDB Homebrew Tap:

brew tap mongodb/brew

3、在macOS終端中驗證安裝先決條件:

brew tap | grep mongodb

4、安裝MongoDB

brew install mongodb-community@4.4

注意:安裝包括:

• mongod 服務器,

• mongos 分片集群查詢路由器,

• mongo 外殼

請參閱此屏幕截圖:

在此處輸入圖片說明

最后將 MongoDB(即 mongod 進程)作為 macOS 服務運行,發出以下命令:

brew services start mongodb-community@4.4

截屏:

在此處輸入圖片說明

在您的終端中嘗試此代碼:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 

接着:

brew tap mongodb/brew  

最后:

brew install mongodb-community@4.0
~ % brew services run mongodb-community
/usr/local/opt/mongodb-community/homebrew.mxcl.mongodb-community.plist: service already loaded

Error: Failure while executing
/bin/launchctl bootstrap gui/501 /usr/local/opt/mongodb-community/homebrew.mxcl.mongodb-community.plist
exited with 17.

@simba,謝謝我的努力:

brew tap mongodb/brew
brew install mongodb-community
brew services start mongodb-community

在 MacOs 中,Catalina 對我來說不能正常工作。

安裝后( https://zellwk.com/blog/install-mongodb/ )我必須添加權限到“/tmp/mongodb-27017.sock”

sudo chown -R `id -un` /tmp/mongodb-27017.sock

並且命令“mongod”似乎忽略了“/usr/local/etc”中的配置文件(mongod.conf),因此我必須始終使用 dbpath 參數啟動它

mongod --dbpath /usr/local/var/mongodb

即使在配置文件中指定了相同的路徑。

還對配置文件使用“mongod”對我不起作用

mongod -f /usr/local/etc/mongod.conf

要么

mongod --config /usr/local/etc/mongod.conf

我通過 brew 服務解決了啟動 mongodb 的所有這些問題。 這運行良好,沒有問題,並從正確的配置文件中獲取參數。

brew services run mongodb-community

只是 go 對於

 brew tap mongodb/brew

操作系統更新時,Homebrew 有時不會安裝在 Max 中,例如最近的 Max OS Ventura - 它不受支持,我們可以通過在終端中使用一些命令快速安裝 Mongo DB 而無需 Homebrew,請在此處查看詳細信息: https:/ /medium.com/@pratheushcmohan/install-mongodb-in-mac-without-using-home-brew-23b2556ff930

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM