Is it possible to install both mongodb 2.6 and 3.2 on the same Mac? I’ve been using mongodb 3.2 (Installed with homebrew) for a while but needed to install 2.6 to support an older project. I used brew install homebrew/versions/mongodb26 and got some issues with conflicting files, which I could sort out later.

Possible conflicting files are:
/usr/local/bin/bsondump -> /usr/local/Cellar/mongodb/3.2.10/bin/bsondump
/usr/local/bin/mongo -> /usr/local/Cellar/mongodb/3.2.10/bin/mongo
/usr/local/bin/mongod -> /usr/local/Cellar/mongodb/3.2.10/bin/mongod
/usr/local/bin/mongodump -> /usr/local/Cellar/mongodb/3.2.10/bin/mongodump
/usr/local/bin/mongoexport -> /usr/local/Cellar/mongodb/3.2.10/bin/mongoexport
/usr/local/bin/mongofiles -> /usr/local/Cellar/mongodb/3.2.10/bin/mongofiles
/usr/local/bin/mongoimport -> /usr/local/Cellar/mongodb/3.2.10/bin/mongoimport
/usr/local/bin/mongooplog -> /usr/local/Cellar/mongodb/3.2.10/bin/mongooplog
/usr/local/bin/mongoperf -> /usr/local/Cellar/mongodb/3.2.10/bin/mongoperf
/usr/local/bin/mongorestore -> /usr/local/Cellar/mongodb/3.2.10/bin/mongorestore
/usr/local/bin/mongos -> /usr/local/Cellar/mongodb/3.2.10/bin/mongos
/usr/local/bin/mongosniff -> /usr/local/Cellar/mongodb/3.2.10/bin/mongosniff
/usr/local/bin/mongostat -> /usr/local/Cellar/mongodb/3.2.10/bin/mongostat
/usr/local/bin/mongotop -> /usr/local/Cellar/mongodb/3.2.10/bin/mongotop

But if I try to start mongod, by running /usr/local/Cellar/mongodb/3.2.10/bin/mongod I get the error 2016-11-15T14:26:08.132+0000 [initandlisten] exception in initAndListen: 28574 Cannot start server. Detected data files in /data/db created by storage engine 'wiredTiger'. The configured storage engine is 'mmapv1'., terminating.

I’ve also lost my database for 3.2, which appears to have been overwritten while installing 2.6.

Has anyone got this working?


It is possible to install mongodb 2.x and 3.x at the same time - you have to rename some files and folders and modify config and plist files though. This will separate the old and the new MongoDB executables/config and the databases:

  • Uninstall any mongodb install in brew
  • Tap brew versions with brew tap homebrew/versions
  • Install mongodb 2.6.12 with brew install mongodb26
  • Rename all fourteen "mongodb26" soft links in /usr/local/bin (e.g. bsondump to bsondump2, mongo to mongo2 etc)
  • Rename /usr/local/etc/mongod.conf to /usr/local/etc/mongod2.conf
  • Rename /usr/local/var/mongodb to /usr/local/var/mongodb2
  • Rename /usr/local/var/log/mongodb to /usr/local/var/log/mongodb2
  • Modify /usr/local/etc/mongod2.conf to reflect the changes above (path and dbpath) and a different port in the net section (e.g. port: 37017)
  • Modify /usr/local/Cellar/mongodb26/2.6.12/homebrew.mxcl.mongodb26.plist to reflect the changes above (log directories and config file)
  • Install mongodb brew install mongodb. This is MongoDB 3

MongoDB 3 will be installed with the default file and folder names then. If MongoDB 2 should be your "default" Mongo DB, install mongodb first and rename everything to *3 (instead of *2). Then install mongodb26 with brew.

Depending on your needs copy the plists to your LaunchAgents folder, if you want to launch either mongodb version while logging in:

cp /usr/local/Cellar/mongodb26/2.6.12/homebrew.mxcl.mongodb26.plist ~/Library/LaunchAgents/
cp /usr/local/Cellar/mongodb/3.2.10/homebrew.mxcl.mongodb.plist ~/Library/LaunchAgents/

and load both plists:

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb26.plist 
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist 

Both mongo daemons should run independently from each other at the same time (at least in my testing VM they did).

If you want to start either mongod manually don't forget to use the renamed mongod command and config file:

mongod2 --config /usr/local/etc/mongod2.conf #mongodb26
mongod --config /usr/local/etc/mongod.conf #mongodb3

I know this is an old question but I was looking for a way to have version 4.x and 3.x and found this to be the easiest solution.

Install the versions of MongoDB you want with brew.

You can find which versions are available with brew search mongo. If you don't see the version you want run brew update. I'm installing the latest version (4) and version 3.6:

brew install mongodb
brew install mongodb@3.6

Start the version you want with brew service

brew services start mongodb

Switch to a different version:

  1. Make sure you are backwards compatible:

    mongo --eval 'db.adminCommand({setFeatureCompatibilityVersion: "3.6"})'

  2. Stop mongod:

    brew services stop mongodb

  3. Unlink the current version of MongoDB:

    brew unlink mongodb

  4. Link the new version of MongoDB:

    brew link --force mongodb@3.6

  5. Start MongoDB version 3.6:

    brew services start mongodb@3.6

  6. Check your version:

    mongo --version


this could be the need to create another folder(ex: mongodb2) dbpath for the second instance, and run it in different port(ex: 27018)

mongod --dbpath /usr/local/var/mongodb2 --port 27018

originally found on https://stackoverflow.com/questions/15124610/multiple-instances-of-mongo-db-on-same-server

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .