使用Homebrew启动/停止MongoDB

Kno*_*uch 8 macos homebrew mongodb

我正在使用mac osx 10.10.5

在执行这些步骤之前和之后已经多次询问过这个问题,我注意到了奇怪的行为.

这些是我采取的步骤

brew tap gapple/services
brew install mongodb
Run Code Online (Sandbox Code Playgroud)

这将安装产品,现在brew services list我可以看到mongodb处于停止状态.

当我尝试启动该过程时,brew services start mongodb我收到错误

错误:无法读取plist mongodb!

好.我用Google搜索了一个解决方案

mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/mongodb/3.0.6/homebrew.mxcl.mongodb.plist ~/Library/LaunchAgents/
Run Code Online (Sandbox Code Playgroud)

现在,一旦复制文件,当我这样做时brew services list... mongo进程自动运行.

现在当我这样做时brew services stop mongodb

Error: Service `mongodb` not running, wanna start it? Try `brew services start mongodb`
Run Code Online (Sandbox Code Playgroud)

现在这很奇怪,因为只是在最后一步它说它的运行.现在当我这样做

mongodb services list它说服务已停止.(所以上面的停止命令确实有效.即使它引发了错误).

现在,如果我这样做

brew services start mongodb
Run Code Online (Sandbox Code Playgroud)

它给出错误错误:无法读取plist mongodb!

现在,如果我再次复制该文件

cp /usr/local/Cellar/mongodb/3.0.6/homebrew.mxcl.mongodb.plist ~/Library/LaunchAgents/
Run Code Online (Sandbox Code Playgroud)

该服务自动开始运行.

我觉得整件事真的很奇怪.我想要的是一个干净的方式来开始停止mongo数据库服务.虽然这个网站(和其他地方)有许多线程......但它们不起作用或只是有奇怪的行为.

Abh*_*ash 19

brew services start/restart/stop mongodb-community@4.0
Run Code Online (Sandbox Code Playgroud)


小智 12

对我来说,我有多个版本的mongodb,当我尝试在它们之间切换时,我收到了这个错误

Error: Could not read the plist for `mongodb26`!
Run Code Online (Sandbox Code Playgroud)

这就是我为启动mongodb26服务所做的.

brew unlink mongodb24
brew link mongodb26
brew services start mongodb26
Run Code Online (Sandbox Code Playgroud)


dam*_*eez 11

您可以通过执行brew services list 然后作为答案之一列出服务 brew services start [NAME]brew services stop [NAME]


小智 2

我认为你应该看看他们的Github存储库。我不赞成使用gapple/services 。这可能是一个更新的选项。