Ben
Ben

Reputation: 591

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. 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

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. 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. I've uninstalled and reinstalled via homebrew, but just don't know where the culprit lies. Any help is be greatly appreciated.

Upvotes: 1

Views: 12605

Answers (4)

M. Ali
M. Ali

Reputation: 2396

In case you have an older version installed, it's a good idea to check the folder using ls /usr/local/Cellar

I had an installation under a folder called mongodb26 since I had manually chosen to work with MongoDB 2.6. In such a case just doing brew uninstall mongodb won't work. I had to do brew uninstall mongodb26. Just a little good thing to know.

Upvotes: -1

Ben
Ben

Reputation: 591

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. I removed it from launchctl as advised in this rather old post, then stopped mongod by running the following from the mongo shell:

> 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

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

Restarted the machine and all seems to be well running 2.4.9.

Upvotes: 1

lciamp
lciamp

Reputation: 685

it's brew update and then brew upgrade mongodb not brew update mongo.

Upvotes: 1

BigDataKid
BigDataKid

Reputation: 1227

Based on the fact you are running MongoDB in OS X, here are my assumptions:

  1. This is not a PRODUCTION system
  2. This is a sandbox, used to developand/or learn MongoDB.
  3. You are OK losing all the data you currently have on this MongoDB instance

If all of my 3 assumptions are true you can just go and manually delete all mongoDB executables. 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.

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/

This link has instructions for re-installing MongoDB: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/

Please let me know if you have any problems.

Upvotes: 4

Related Questions