Navigation

Alpha Release of MongoDB CLI

This is a pre-release early version of MongoDB CLI. Do not use MongoDB CLI to manage production environments.

Install the MongoDB CLI

You can use the MongoDB Command Line Interface (mongocli) to deploy and manage MongoDB clusters in Atlas, MongoDB Cloud Manager, and Ops Manager.

Considerations

Ops Manager Compatibility

MongoDB CLI is compatible with Ops Manager v4.2.0 and later.

Prerequisites

To install the MongoDB CLI, you need the following tools:

  1. Git.
  2. Go v1.13 or newer.

Procedure

1

Install the MongoDB CLI.

To install MongoDB CLI, you can either:

  1. Clone the GitHub repository and install with Go or
  2. Download and extract the binary.

Once downloaded, you can run the binary from any directory. Because you don’t need to install the MongoDB CLI into a global location, you can use it on shared hosts and other systems where you don’t have a privileged account.

  1. Clone the repository:

    git clone https://github.com/mongodb/mongocli.git
    
  2. Change directories to your the local repostiory:

    cd mongocli
    
  3. Install MongoDB CLI using Go.

    make install
    
  1. Navigate to the available releases on GitHub.
  2. Click the name of the release you want to install.
  3. In the Assets section at the end of the Changelog, locate the binary for your operating system.
  4. Download and extract the binary.
  5. Run the executable file.
2

Add mongocli to your PATH.

To run mongocli commands from anywhere in your system, you must either:

  1. Add the location of the executable to your PATH or
  2. Move the executable to a directory in your PATH.

You can accomplish this in several ways, depending on your personal settings and environment. Consult the documentation for your shell and operating system for more examples.

Example

In the following example, the user downloads and installs the MongoDB CLI by cloning the GitHub repository. The mongocli executable file saves to the location specified by your $GOPATH environment variable. The default location is $HOME/go on Unix systems and %USERPROFILE%\go on Windows.

The user then adds this directory to their PATH:

export PATH="$HOME/go:$PATH"

Example

In the following example, the user downloads and extracts a binary for the MongoDB CLI to the /mcli_0.0.1-macOS_x86_64 directory.

The user then moves the executable file to a directory already in their PATH:

cd mcli_0.0.1-macOS_x86_64
mv mongocli /usr/local/bin
3

Verify your installation.

To verify your mongocli installation, run the help command:

mongocli help

The command returns the available commands and options for the MongoDB CLI.

Next Steps

Configure the MongoDB CLI for your environment.