今天在使用brew install mongodb
安裝 mongodb 時git
提示:Error: No available formula with the name 'mongodb'github
經查找緣由以下:mongodb
MongoDB再也不是開源的了,而且已經從Homebrew中移除 #43770shell
新的安裝方式能夠參考github主頁給的提示:https://github.com/mongodb/ho...數據庫
brew tap mongodb/brew
安裝MongoDB社區服務器的最新可用生產版本(包括全部命令行工具)。這將安裝MongoDB 4.2.x:macos
$ brew install mongodb-community
安裝MongoDB社區服務器和命令行工具的最新4.2.x生產版本:服務器
$ brew install mongodb-community@4.2
安裝MongoDB社區服務器和命令行工具的最新4.0.x生產版本:工具
$ brew install mongodb-community@4.0
安裝MongoDB社區服務器和命令行工具的最新3.6.x生產版本:spa
$ brew install mongodb-community@3.6
僅安裝最新的mongoshell以鏈接到遠程MongoDB實例:命令行
$ brew install mongodb-community-shell
若是報這個錯⬇️
An exception occurred within a child process An exception occurred within a child process: DownloadError: Failed to download resource "mongodb-community" Download failed: https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-4.2.0.tgz
從新執行一下上面的命令
brew install mongodb-community@4.2 (我裝的這個)
配置文件:/usr/local/etc/mongod.conf 日誌目錄路徑:/usr/local/var/log/mongodb 數據目錄路徑:/usr/local/var/mongodb
mongod做爲服務運行
若要launchd啓動mongod當即重啓也登陸時,使用
brew services start mongodb-community
若是您mongod做爲服務進行管理,它將使用上面列出的默認路徑。要中止服務器實例,請使用:
brew services stop mongodb-community
若是您不想要或不須要後臺MongoDB服務,您能夠運行:
mongod --config /usr/local/etc/mongod.conf
注意:若是您不包含--config帶有配置文件路徑的選項,則MongoDB服務器沒有默認配置文件或日誌目錄路徑,並將使用數據目錄路徑/data/db。
要mongod手動關閉,請使用admin數據庫並運行db.shutdownServer():
mongo admin --eval "db.shutdownServer()"