mongodb version management
Last updated 6 days ago by stennie .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install m 
SYNC missed versions from official npm registry.

m - MongoDB Version Manager

m helps you download, use, and manage multiple versions of the MongoDB server and command-line tools.

This can be useful for development & testing environments. For example, testing release upgrades/downgrades or potential behavior differences between versions.

Where possible m will try to download the distro-specific binaries for your O/S and version. If a binary appears to be unavailable, m will ask if you want to try building from source.

NOTE: Building MongoDB from source requires you to preinstall all of the relevant dependencies & toolchain to build the desired version of MongoDB. Installing those is outside the scope of what m does.


To install binary packages m requires a 64-bit O/S which:

Environments that should work include:

  • Linux (RHEL/CentOS, Debian/Ubuntu, Amazon Linux)
  • macOS 10.11 (El Capitan) and later
  • Windows 10 with Ubuntu on Windows
  • Docker using a supported Linux distro


m is a bash script which can be installed & updated via npm for convenience:

$ npm install -g m

or installed by cloning the GitHub repo and running make install:

$ git clone git://github.com/aheckmann/m.git && cd m && make install

or fetched via wget and copied to a location of your choice:

$ wget https://raw.githubusercontent.com/aheckmann/m/master/bin/m && chmod +x ./m

Downloading MongoDB Binaries

Specify a MongoDB server version to try download a binary package (if available for your current O/S) or switch to a previously downloaded copy. After m successfully downloads or switches to a specified version of MongoDB, those binaries will become the default in the install path (typically /usr/local/bin/; see Details below for more information).

$ m 3.2.16
$ m 3.4.9

You can also specify a release series to download the latest available revision:

$ m 3.6
$ m 4.0

List installed binaries:

$ m

ο 3.4.9

Use or download the latest official release:

$ m latest

Use or download the stable official release:

$ m stable

Check what the latest available release is:

$ m --latest
$ m --latest 3.6

Check what the current stable release is:

$ m --stable
$ m --stable 3.6

Download a custom or patched version of MongoDB from a tarball:

$ m custom 3.5.13-me https://github.com/mongodb/mongo/tarball/r3.5.13

Download and build a version of MongoDB from source (NOTE: assumes build requirements are installed):

$ m 3.6.5 source

Download an Enterprise release:

$ m 3.4.9-ent

Select a MongoDB version without prompting for confirmation if a download is required:

$ yes | m 4.0.0

Downloading MongoDB Database Tools

The Database Tools (mongodump, mongorestore, etc.) are now released separately from the server. You can use m to manage your MongoDB Database Tools version independently of your MongoDB server and shell versions.

List available Database Tools versions:

$ m tools ls

List installed Database Tools versions:

$ m tools installed

Use or download the latest stable release of the Database Tools:

$ m tools stable

Use or download a specific version of the Database Tools:

$ m tools 100.0.0

Removing Binaries

Remove some previously installed versions:

$  m rm 3.2.16 3.5.13-me

Binary Usage

Multiple versions of MongoDB can be downloaded and targeted directly.

Ask m for the binary path for a specific version that has already been downloaded:

$ m bin 3.4.9

Ask m for the binary path for the latest revision of a release already downloaded:

$ m bin 3.6

Start up mongod 3.4.9 regardless of the active version:

$ m use 3.4.9 --port 29000 --dbpath /data/3.4.9/

Execute a script with the 3.4.9 mongo shell regardless of the active version:

$ m shell 3.4.9 some.js

Execute a script with a 3.4.9 mongo shell and some additional flags:

$ m shell 3.4.9 --port 29000 --norc

When installing or changing the active version you might want to run custom scripts:

$ m pre install /path/to/my/script
$ m post install /path/to/script
$ m pre change /path/to/my/script
$ m post change /path/to/script

Multiple scripts may be added for any event. To add two pre change scripts:

$ m pre change /path/to/script1
$ m pre change /path/to/script2

Scripts are executed in the order they were added.

List all pre change hooks:

$ m pre change


List all post install hooks:

$ m post install


To remove a post install hook:

$ m post install rm /path/to/scriptB

To remove all post install hooks:

$ m post install rm


Output from m --help:

  Usage: m [options] [COMMAND] [config]


    m                            Output versions installed
    m stable [config ...]        Install or activate the latest stable MongoDB release
    m latest [config ...]        Install or activate the latest MongoDB release (including dev & RCs)
    m X.Y                        Install or activate the latest patch release for MongoDB X.Y (eg. 3.6)
    m <version> [config ...]     Install and/or use MongoDB <version>
    m <version> --legacy         Install generic Linux version (does not include SSL)
    m custom <version> <tarball> [config ...]  Install custom MongoDB <tarball> with [args ...]
    m use <version> [args ...]   Execute mongod <version> with [args ...]
    m shard <version> [args ...] Execute mongos <version> with [args ...]
    m shell <version> [args ...] Open a mongo shell <version> with [args ...]
    m bin <version>              Output bin path for <version>
    m rm <version ...>           Remove the given version(s)
    m --stable                   Output the latest stable MongoDB version available
    m --stable X.Y                .. for release series X.Y (eg. 3.6)
    m --latest                   Output the latest MongoDB version available (including dev & RCs)
    m --latest X.Y                .. for release series X.Y (eg. 3.6)
    m ls                         Output the versions of MongoDB available
    m installed [--json]         Output installed versions available (optionally, in JSON format)
    m src <version>              Output the url for source used for the given <version>
                                   (useful if installed from source)
    m pre <event> [script]       Declare one or list scripts to execute before <event>
                                   (scripts must use absolute paths)
    m post <event> [script]      Declare one or list scripts to execute after <event>
                                   (scripts must use absolute paths)
    m pre <event> rm [script]    Remove pre <event> script
    m post <event> rm [script]   Remove post <event> script
    m tools stable               Install or activate the latest stable Database Tools release
    m tools X.Y.Z                Install or activate the Database Tools X.Y.Z 
    m tools ls                   Output the versions of the Database Tools available
    m tools installed [--json]   Output installed versions of the Database Tools available


    change   Occurs when switching MongoDB versions
    install  Occurs when installing a previously uninstalled MongoDB version


    -V, --version   Output current version of m
    -h, --help      Display help information


    custom     c
    installed  lls
    shard      sd, mongos
    shell      s, sh, mongo
    list       ls, available, avail
    use        as, mongod
    which      bin


By default m downloads MongoDB binaries to /usr/local/m/versions in subdirectories named after the release version (3.2.16, 3.4.9, ...). MongoDB Database Tools binaries are downloaded to /usr/local/m/tools/versions in subdirectories named after the release version (100.0.0, 100.0.1, ...). Activated MongoDB binaries are symlinked into the bin directory in /usr/local. To alter where m operates, export the M_PREFIX environment variable with your preferred path prefix.

Previously downloaded versions of MongoDB can be activated using m <version> or selected using of the variations in the Binary Usage section above.




Yes tj, this is nearly identical to n. Huge thanks!


This software is not supported by MongoDB, Inc. under any of their commercial support subscriptions or otherwise. Any usage of m is at your own risk. Bug reports, feature suggestions, and questions can be posted in the Issues section on GitHub.

Current Tags

  • 1.6.0                                ...           latest (6 days ago)

31 Versions

  • 1.6.0                                ...           6 days ago
  • 1.5.6                                ...           a year ago
  • 1.5.5                                ...           a year ago
  • 1.5.4                                ...           2 years ago
  • 1.5.3                                ...           2 years ago
  • 1.5.2                                ...           2 years ago
  • 1.5.1                                ...           2 years ago
  • 1.5.0                                ...           2 years ago
  • 1.4.1                                ...           3 years ago
  • 1.4.0                                ...           3 years ago
  • 1.3.3                                ...           3 years ago
  • 1.3.1                                ...           4 years ago
  • 1.3.0                                ...           4 years ago
  • 1.2.2                                ...           4 years ago
  • 1.2.1                                ...           5 years ago
  • 1.2.0                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.1                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
  • 0.2.6                                ...           7 years ago
  • 0.2.5                                ...           7 years ago
  • 0.2.4                                ...           8 years ago
  • 0.2.3                                ...           8 years ago
  • 0.2.2                                ...           8 years ago
  • 0.2.0                                ...           8 years ago
  • 0.1.2                                ...           8 years ago
  • 0.1.1                                ...           8 years ago
  • 0.1.0                                ...           8 years ago
  • 0.0.3                                ...           8 years ago
  • 0.0.2                                ...           8 years ago
  • 0.0.1                                ...           8 years ago
Maintainers (2)
Today 1
This Week 2
This Month 54
Last Day 0
Last Week 39
Last Month 18
Dependencies (0)
Dev Dependencies (0)

Copyright 2014 - 2016 © taobao.org |