How to install earlier version of mongodb with homebrew?

后端 未结 7 719
一整个雨季
一整个雨季 2020-12-22 20:07

I\'m on osx6.8 and need to install an earlier version of Mongodb, how do I install an earlier version with HomeBrew? The below didn\'t work :(

dream-2:app2         


        
7条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-22 20:27

    Note: In September 2019 mongodb was removed from homebrew core, so these instructions have been updated to use mongodb-community instead, installed from the external tap.

    If your current installation is still the pre-September mongodb package then you will need to use that name when you unlink, stop, relink and start, on the lines marked with #*# below.

    Another option is to simply upgrade away from the deprecated package now.

    I already have the latest version of mongo installed, thanks to.

    brew tap mongodb/brew
    
    brew install mongodb-community
    

    But I want to switch to the old version sometimes. First, install it:

    brew search mongo
    
    brew install mongodb-community@3.2
    

    Let's stop the current mongodb, if it is running:

    brew services stop mongodb/brew/mongodb-community           #*#
    
    # or if you had started it manually
    
    killall mongod
    

    Now I want 3.2 on my PATH instead of the latest:

    brew unlink mongodb-community                               #*#
    
    brew link --force mongodb-community@3.2
    

    (Apparently it needs --force because it is keg-only.)

    Now I have 3.2 on my PATH, I can start the test DB:

    mongod --version
    
    brew services start mongodb/brew/mongodb-community
    
    # or start your own mongod from the command-line
    

    When I am finished, I can do the reverse to switch back to the latest version:

    brew services stop mongodb/brew/mongodb-community
    
    brew unlink mongodb-community@3.2
    
    brew link mongodb-community                                 #*#
    
    brew services start mongodb/brew/mongodb-community          #*#
    

    And restart again.

提交回复
热议问题