0

When I start the mongo shell from ~/Downloads/mongodb-osx-x86_64-2.4.5/bin, it starts up version 2.4.5

 ./mongo
MongoDB shell version: 2.4.5

That's the version I just downloaded.However, when I run the mongo command from anywhere else in my terminal it starts a different version. I think this is because I (obviously) installed Mongo previously.

MongoDB shell version: 2.2.0
connecting to: test

What do I need to do to make 2.4.5 respond to 'mongo' from anywhere in the terminal (i.e. to replace 2.2.0 with 2.4.5)

BrainLikeADullPencil
  • 11,313
  • 24
  • 78
  • 134

2 Answers2

2

There is no reason why you can't have multiple concurrent releases of mongo installed. You can have multiple versions of mongo and each running a different storage engine and also participate in a replica set.

Here are 3 installations on my mac e.g.

drwxr-xr-x@ 18 rohitsood  staff    612 Aug 21 18:53 mongodb-osx-x86_64-2.6.3
drwxr-xr-x@  6 rohitsood  staff    204 Jan  4 20:25 mongodb-osx-x86_64-3.0.8
drwxr-xr-x@  8 rohitsood  staff    272 Jan  7 12:31 mongodb-osx-x86_64-3.2.0

if you want to start a mongod instance that maps to version 3.2 (the latest) then ensure your path points to it.

Go to you Home (~) folder and open the ".profile" file to make these changes

Here's what mine looks like for reference

#Set up MongoDB
#export MONGODB_HOME=/Users/rohitsood/servers/mongodb-osx-x86_64-2.6.3
#export MONGODB_HOME=/Users/rohitsood/servers/mongodb-osx-x86_64-3.0.8
export MONGODB_HOME=/Users/rohitsood/servers/mongodb-osx-x86_64-3.2.0
export PATH=${MONGODB_HOME}/bin:${PATH}

Open a new terminal - and mongo should work as expected.

Sood
  • 169
  • 1
  • 6
1

I just needed to update my path in bash_profile file to the location of the newer version

export PATH="/path/to/monogdb/bin:$PATH"
BrainLikeADullPencil
  • 11,313
  • 24
  • 78
  • 134