简体   繁体   English

如何在OS X上卸载过时的mongodb版本?

[英]How to uninstall outdated version of mongodb on OS X?

I have an outdated version (1.8.2) of mongodb on OS X and I cannot for the life of me figure out how to get rid of it. 我在OS X上安装了过时的mongodb版本(1.8.2),我一生无法解决如何摆脱它。 It was installed several years ago, I think with homebrew. 认为是几年前安装的。 Upgrading it using brew update && brew upgrade mongo got me the newest version of the mongo client (2.4.9) but when I open the client and run 使用brew update && brew upgrade mongo对其进行brew update && brew upgrade mongo我提供了mongo客户端的最新版本(2.4.9),但是当我打开客户端并运行时

use admin
db.runCommand({buildInfo:1})

I get 我懂了

{
  ...
  "version" : "1.8.2",
  ...
}

When I ask 当我问

which mongo

I get 我懂了

/usr/local/bin/mongo

which is a symlink (as expected) to 这是(预期的)符号链接

/usr/local/Cellar/mongodb/2.4.9/bin/mongo

also

/usr/local/opt/mongodb

appears to be properly symlinked to 似乎正确地链接到

/usr/local/Cellar/mongodb

Looking in /usr/local/Cellar/mongodb , I found two outdated versions (one of them 1.8.2) and moved both of them to see what would happen. /usr/local/Cellar/mongodb ,我发现了两个过时的版本(其中一个是1.8.2),并移动了两个版本以查看会发生什么。 The answer is nothing. 答案是什么。 Mongo Client still starts and reports the client version to be 2.4.9, but db.runCommand({buildInfo:1}) still reports 1.8.2. Mongo Client仍会启动,并报告客户端版本为2.4.9,但是db.runCommand({buildInfo:1})仍报告1.8.2。 I've uninstalled and reinstalled via homebrew, but just don't know where the culprit lies. 我已经通过自制软件卸载并重新安装了,但是只是不知道罪魁祸首在哪里。 Any help is be greatly appreciated. 任何帮助将不胜感激。

Based on the fact you are running MongoDB in OS X, here are my assumptions: 基于您在OS X中运行MongoDB的事实,这是我的假设:

  1. This is not a PRODUCTION system 这不是PRODUCTION系统
  2. This is a sandbox, used to developand/or learn MongoDB. 这是一个沙箱,用于开发和/或学习MongoDB。
  3. You are OK losing all the data you currently have on this MongoDB instance 您可以丢失该MongoDB实例上当前拥有的所有数据

If all of my 3 assumptions are true you can just go and manually delete all mongoDB executables. 如果我的3个假设全部正确,则可以手动删除所有mongoDB可执行文件。 They should all probably in the same directory. 它们可能都应该在同一目录中。 Move that directory to the trash, as well as the contents of the dbpath and log path. 将该目录以及dbpath和日志路径的内容移至回收站。

Running the getCmdLineOpts command in the mongo shell will help you identify both the dbpath and log path http://docs.mongodb.org/manual/reference/command/getCmdLineOpts/ 在mongo shell中运行getCmdLineOpts命令将帮助您识别dbpath和日志路径http://docs.mongodb.org/manual/reference/command/getCmdLineOpts/

This link has instructions for re-installing MongoDB: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/ 此链接包含有关重新安装MongoDB的说明: http : //docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/

Please let me know if you have any problems. 如果您有任何问题,请告诉我。

它是brew update ,然后brew upgrade mongodb而不是brew update mongo

Thanks for the input, you guys. 谢谢你们的投入。 The answer turned out to be a particularly stubborn version of mongod. 答案竟然是蒙古的一个特别顽固的版本。 It was set to start on system startup using launchctl, and so it persisted even though I restarted my machine. 它被设置为使用launchctl在系统启动时启动,因此即使我重新启动计算机,它也仍然存在。 I removed it from launchctl as advised in this rather old post , then stopped mongod by running the following from the mongo shell: 我按照这篇相当老的文章中的建议从launchctl中删除了它,然后通过从mongo shell运行以下命令停止了mongod:

> use admin
> db.shutdownServer()

After that I copied the homebrew mongo plist file from /usr/local/Cellar/mongodb/2.4.9/homebrew.mxcl.mongodb.plist into /Library/LaunchDaemons and ran 之后,我从/usr/local/Cellar/mongodb/2.4.9/homebrew.mxcl.mongodb.plist复制了自制的mongo plist文件到/Library/LaunchDaemons并运行

$ sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.mongodb.plist

Restarted the machine and all seems to be well running 2.4.9. 重新启动计算机,似乎所有2.4.9都运行良好。

In case you have an older version installed, it's a good idea to check the folder using ls /usr/local/Cellar 如果您安装了旧版本,最好使用ls /usr/local/Cellar检查文件夹

I had an installation under a folder called mongodb26 since I had manually chosen to work with MongoDB 2.6. 因为我手动选择使用MongoDB 2.6,所以我在名为mongodb26的文件夹下进行了安装。 In such a case just doing brew uninstall mongodb won't work. 在这种情况下,仅执行brew uninstall mongodb将不起作用。 I had to do brew uninstall mongodb26 . 我不得不做brew uninstall mongodb26 Just a little good thing to know. 只是要知道一点好处。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM