Updated on 2022-02-22 GMT+08:00

How Can I Install a MongoDB Client?

MongoDB official website provides client installation packages for different OSs. Download the official binary installation package at https://www.mongodb.com/download-center#community.

The following uses Red Hat Linux 7 and MongoDB 3.4.0 as examples to describe how to obtain the required installation package and install the MongoDB client.

Procedure

  1. Obtain the installation package.

    1. Log in at https://www.mongodb.com/download-center/community.
    2. Choose Server, select RHEL 7.0 Linux 64-bit x64 for OS, and click All version binaries. Figure 1 shows an example.
      Figure 1 MongoDB official webpage
    3. Open the downloading page, click linux/mongodb-linux-x86_64-rhel70-3.4.0.tgz to download the binary installation package of MongoDB 3.4.0. Figure 2 shows an example.
      Figure 2 Downloading page

  2. Upload the installation package to the ECS. For details about how to log in to an ECS, see How Do I Create and Log In to an ECS?.
  3. Decompress the installation package on the ECS.

    tar zxvf mongodb-linux-x86_64-rhel70-3.4.0.tgz

  4. Obtain the client tool from the bin directory of the installation package.

    cd mongodb-linux-x86_64-rhel70-3.4.0/bin

    The common tools are as follows:

    • MongoDB client mongo
    • Data export tool mongoexport
    • Data import tool mongoimport

  5. Before using a client tool, assign the execute permission to it.

    • Run the chmod +x mongo command to grant a client permission to connect to a DB instance.
    • Run the chmod +x mongoexport command to grant a client permission to export data.
    • Run the chmod +x mongoimport command to grant a client permission to import data.

  6. Connect to a DB instance from the client. For details, see section "Connecting to a DB Instance" in Document Database Service Getting Started