Mongo shell on windows

MongoDB is a document-oriented database created by MongoDB Inc. to provide software database services. It is classified as a NoSQL database due to its document-oriented nature. Meanwhile, MongoDB documents are represented in a JSON-like structure.

It provides high scalability because of its ability to be updated on the fly without causing downtimes. MongoDB provides shell interactions via tools like Mongo and mongosh. MongoDB shell or mongosh is a superset of mongo, providing improved syntax highlighting, command history, and improved logging. Mongosh works typically like mongo, so a user doesn’t have to learn new syntax.

In this article, you will get to know how to start the MongoDB server and Windows MongoDB Shell Installation in 3 easy steps.

What is MongoDB?

MongoDB is a well-known open-source NoSQL database built on the C++ programming language. MongoDB is a document-oriented database that uses JSON-like documents and a Dynamic Schema to store information. It means that while saving your data, you won’t have to worry about the Data Structure, the number of fields, or the types of fields used to store values. JSON objects are identical to MongoDB Documents.

You can change the structure of records by simply adding new fields or deleting existing ones (which MongoDB refers to as Documents). This functionality can be used to describe Hierarchical Relationships, Store Arrays, and other more sophisticated Data Structures in MongoDB. MongoDB is being utilized to store enormous volumes of data by a number of digital companies, including Facebook, eBay, Adobe, and Google.

Enable Seamless MongoDB ETL with Hevo’s No-Code Data Pipelines

With Hevo Data, you can easily integrate MongoDB with a wide range of destinations. While we support MongoDB as a source, our platform ensures seamless data migration to the destination of your choice. Simplify your data management and enjoy effortless integrations.

Check out how Hevo can be of help:

  • No-Code Data Pipelines: Set up data transfers from MongoDB to your desired destination without writing a single line of code.
  • Automated Schema Mapping: Automatically detect and map MongoDB schemas to match the destination structure, ensuring accurate data transfer.
  • Secure Data Transfer: Ensure your data is protected during migration with encryption and secure connections.

Explore Hevo’s features and discover why it is rated 4.3 on G2 and 4.7 on Software Advice for its seamless data integration.

Get Started with Hevo for Free

Key Features of MongoDB

In comparison to other traditional databases, MongoDB has a number of unique features that make it a superior choice. The following are some of these attributes:

  • Index-based Document: In a MongoDB database, every field in the Document is indexed with Primary and Secondary Indices, making it easier to get data from the pool.
  • Horizontal Scalability: It is possible with MongoDB’s sharding. The practice of distributing data over numerous servers is known as sharding. The Shard Key is used to partition a huge quantity of data into data chunks, which are then uniformly dispersed among Shards that span several Physical Servers.
  • Schema-Less Database: This type of Database stores many sorts of documents in a single collection (the equivalent of a table). To put it another way, a single collection in the MongoDB database can hold numerous documents, each having its own set of Fields, Content, and Size. It is not required that one document be comparable to another, as is the case with Relational Databases. MongoDB provides a lot of freedom to consumers because of this capability.
  • Replication: MongoDB provides high availability of data by generating several copies of the data and sending these copies to a separate Server, allowing the data to be retrieved even if one server fails

MongoDB Interface

Image Source

When you first start using MongoDB, you’ll notice how user-friendly the interface is, especially if you’re coming from a background in SQL. Instead of dealing with rigid tables, you get to work with flexible, JSON-like documents that make organizing and querying data feel intuitive. You can use tools like MongoDB Compass for a visual approach, or stick to the command line if you’re more comfortable there. Either way, you’ll find it pretty easy to dive in and start building.

Installing MongoDB

To start with, to install Windows MongoDB Shell, you need to have MongoDB installed in the first place. If you don’t already have MongoDB installed on your computer, the first section will put you through it just before moving on to the installation of the MongoDB shell. You can skip this section if you have already installed MongoDB on your system.

Before installing MongoDB, it is important to know that there are two editions: the Community Edition and the Enterprise Edition. The major difference between the Community edition(regular enough for developers) and the Enterprise edition is that it provides advanced security options(e.g, LDAP, auditing, log redaction), additional storage engines, real-time server stats, document validation, MongoDB connector for BI, schema analysis, and many more. 

Step 1: Download The Installer

  • Go to the download page at https://www.mongodb.com/try/download/community
  • Choose your OS and your desired MongoDB version.
  • Click Download.

Step 2: Run the MongoDB Installer(a .msi file)

  • Go to your ‘Downloads’ folder.
  • Click on the installer.
  • Follow the instructions.

After completing the installation process, you will find the MongoDB software in your C drive. To view it, go to 

C: Program FilesMongoDBServer{version}bin. 

However, you would notice the presence of any executable alongside mongo-mongod. Mongod is a daemon process that runs in the background. It handles database processes like accessing, retrieval, and updates.

If you try using MongoDB right away, you might have to specify a directory structure every time you need to use it. To avoid this, you need to specify an environment variable for MongoDB, which leads us to step 3. 

Step 3: Specify An Environment Variable

  • Go to your system settings or type “Advanced system settings” in the search bar.
  • Click ‘Environment Variables’ under ‘Advanced’.
  • Click ‘New’ to create an environment variable.
  • Select the ‘Path’ variable and click on ‘Edit’.
  • Change the environment variable to  

C: Program FilesMongoDBServer{version}bin. Where version is the MongoDB version you downloaded.

  • Click Save.

If you run the mongod command now, you would get a log error when the mongod service doesn’t find a data directory.

Step 4: Configure a Data Directory For All MongoDB Files

To configure a data directory for MongoDB, create a directory called ‘MongoDBFiles’ with subdirectories ‘/data/db’. You can do this manually or by typing the command below in the terminal.

> mkdir -p MongoDBFiles/data/db

Make sure you are in the C:/ directory before doing this.

After doing that, type mongodb –dbpathC:/MongoDBFiles/data/db”.

This command will set the directory to store all MongoDB operations on your computer.

Step 5: Run mongo

Now that you’ve configured MongoDB, run ‘mongod’ in the terminal to confirm if it works. The server should be on port 27017(MongoDB’s default port), which you can connect to. However, to connect and use MongoDB, you have to run the mongod server first.

Load your Data from MongoDB to PostgreSQL

Connect your Data from MongoDB to MySQL

Replicate your Data from MongoDB Atlas to Snowflake

Step 6: Test Your Installation

To confirm your installation, run ‘mongo’ in the terminal. You should see a command shell similar to the command prompt that allows you to enter commands. Type ‘show dbs’ to see the list of existing databases.

Windows MongoDB Shell Installation

As said earlier, Mongosh works like the typical mongo predecessor, but it requires a MongoDB shell of version 4.0 or higher. Over to the Windows MongoDB Shell installation steps.

Step 1: Download the Mongosh Installer

  • To begin the Windows MongoDB Shell Install process, go to the download page at https://www.mongodb.com/try/download/shell.
  • Choose your OS and your desired MongoDB version.
  • Click Download.

Step 2: Run the MongoDB Installer(a .msi file)

  • Go to your ‘Downloads’ folder.
  • Click on the installer.
  • Follow the instructions.

Step 3: Connect to A MongoDB Instance

This can be done in two distinct ways:

A) Locally

You can connect to a MongoDB instance locally by running the ‘mongosh’ command. The ‘mongosh’ command will connect to the default MongoDB port – 27017. This method is also equivalent to connecting with a connection string.

> mongosh "mongodb://localhost:27017"

If you need to connect to a specific database, you will have to add the name of the database to the path.

> mongosh "mongodb://localhost:27017/hevodb"

If the connection port can be changed, your MongoDB instance is not on the default. Another way to connect to a mongodb instance is with the command-line option —port.

> mongosh —-port 28089

B) Remote

This can also be done with a connection string and command-line options.

  • With the connection string:
    • Example: mongosh “mongodb://mongodb0.example.com:29058”
    • If the remote host in this case is MongoDB Atlas, copy the URL to replace it.
  • With command-line options:
    • Unlike the local connection, command-line options for remote connection require the –host option. 
    • Example: mongosh –host mongodb0.example.com –port 28015

You have successfully carried out the process of Windows MongoDB Shell installation.

Real-Life Use Cases of Windows MongoDB Shell

The Windows MongoDB Shell is a powerful tool for interacting with MongoDB databases. Here are some real-life use cases where it’s commonly used:

  1. Database Administration: System administrators use the MongoDB shell to monitor and manage databases. Tasks like backing up data, checking system status, or adjusting user permissions are handled directly through the shell.
  2. Data Migration: When moving data between different MongoDB instances or upgrading versions, the MongoDB shell is used to export, import, and manipulate data efficiently.
  3. Quick Querying and Troubleshooting: Developers use the shell to run quick queries or perform data analysis. It’s also useful for troubleshooting issues by running diagnostic commands or examining logs.
  4. Automation and Scripting: MongoDB shell scripts can be written to automate repetitive tasks, like data cleanup, backups, or batch processing, helping improve productivity and reduce manual errors.
  5. Application Development: During application development, developers use the shell to test queries, view documents, and interact with the database to ensure the application is working as expected.

Conclusion

MongoDB is a NoSQL database, document-oriented to be exact. It allows you to update database schemas on the fly without performing migrations like SQL databases. This provides horizontal scaling and performance benefits. This article has shown you the Windows MongoDB Shell installation process for use. In case you want to transfer data into your desired Database/destination, then Hevo Data is the right choice for you! 

For a complete view of business performance, consolidating data from diverse sources like Marketing, Sales, and CRM is essential. Hevo Data simplifies this process by automating data integration, transformation, and loading to your preferred destination. Sign up for a 14-day free trial and experience the feature-rich Hevo suite firsthand. You can also have a look at the unbeatable pricing that will help you choose the right plan for your business needs.

    Frequently Asked Questions

    1. What is the MongoDB shell?

    The MongoDB shell is a command-line interface that allows you to interact with your MongoDB database. It enables you to run queries, manage your database, and perform administrative tasks like backups and data migration.

    2. How to use MongoDB shell on Windows?

    To use the MongoDB shell on Windows, follow these steps:
    1. Install MongoDB on your Windows system.
    2. Open Command Prompt or PowerShell.
    3. Navigate to the MongoDB installation directory or add it to your system’s PATH.
    4. Type mongo to start the MongoDB shell and connect to your local MongoDB instance.

    3. How to check MongoDB shell version?

    To check the MongoDB shell version, open the MongoDB shell and type the following command:
    db.version()
    This will display the version of MongoDB you’re currently using.

    Teniola Fatunmbi is a full-stack software engineer with a keen focus on data analytics. He excels in creating content that bridges the gap between technical complexity and practical application. Teniola’s strong analytical skills and exceptional communication abilities enable him to effectively collaborate with non-technical stakeholders to deliver valuable, data-driven insights.

    MongoDB Shell mongosh is the modern command-line interface for interacting with MongoDB databases. This guide walks you through installing mongosh on Mac, Ubuntu, CentOS, or Windows.

    macOS#

    Homebrew#

    1. Install Homebrew (if not already installed):

      /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    2. Install MongoDB Shell:

      brew install mongosh
    3. Verify installation:

      mongosh --version

    Using Manual Download#

    1. Download the MongoDB Shell package from the MongoDB Download Center

      • Select your macOS version
      • Choose «tgz» as the package format
    2. Extract the downloaded archive:

      tar -zxvf mongosh-*-darwin-x64.tgz
    3. Move the binary to a directory in your PATH:

      sudo cp mongosh-*-darwin-x64/bin/mongosh /usr/local/bin/
    4. Verify installation:

      mongosh --version

    Troubleshooting on macOS#

    • If you see «command not found» after installation:
      export PATH=$PATH:/usr/local/bin
    • For permission issues:
      sudo chmod +x /usr/local/bin/mongosh

    Ubuntu#

    apt#

    1. Import MongoDB GPG key:

      wget -qO- https://www.mongodb.org/static/pgp/server-7.0.asc | sudo apt-key add -

      If that doesn’t work, try:

      wget -qO- https://www.mongodb.org/static/pgp/server-7.0.asc | sudo tee /etc/apt/trusted.gpg.d/mongodb.asc
    2. Add MongoDB repository:

      echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
    3. Update package index:

      sudo apt update
    4. Install MongoDB Shell:

      sudo apt install -y mongodb-mongosh
    5. Verify installation:

      mongosh --version

    Manual Download#

    1. Download the MongoDB Shell package:

      wget https://downloads.mongodb.com/compass/mongodb-mongosh_2.1.1_amd64.deb

      Note: Replace the version number with the latest available

    2. Install the package:

      sudo dpkg -i mongodb-mongosh_2.1.1_amd64.deb
    3. Verify installation:

      mongosh --version

    Troubleshooting on Ubuntu#

    • If you encounter dependency issues:
      sudo apt --fix-broken install
    • For repository key issues:
      sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 656408E390CFB1F5

    CentOS#

    yum/dnf#

    1. Create MongoDB repository file:

      sudo tee /etc/yum.repos.d/mongodb-org-7.0.repo << EOF
      [mongodb-org-7.0]
      name=MongoDB Repository
      baseurl=https://repo.mongodb.org/yum/redhat/\$releasever/mongodb-org/7.0/x86_64/
      gpgcheck=1
      enabled=1
      gpgkey=https://www.mongodb.org/static/pgp/server-7.0.asc
      EOF
    2. Install MongoDB Shell:

      # For CentOS 8+
      sudo dnf install -y mongodb-mongosh
      
      # For CentOS 7
      sudo yum install -y mongodb-mongosh
    3. Verify installation:

      mongosh --version

    Manual Download#

    1. Download the MongoDB Shell package:

      # For CentOS 8+
      wget https://downloads.mongodb.com/compass/mongodb-mongosh-2.1.1.el8.x86_64.rpm
      
      # For CentOS 7
      wget https://downloads.mongodb.com/compass/mongodb-mongosh-2.1.1.el7.x86_64.rpm

      Note: Replace the version number with the latest available

    2. Install the package:

      # For CentOS 8+
      sudo dnf install -y ./mongodb-mongosh-2.1.1.el8.x86_64.rpm
      
      # For CentOS 7
      sudo yum install -y ./mongodb-mongosh-2.1.1.el7.x86_64.rpm
    3. Verify installation:

      mongosh --version

    Troubleshooting on CentOS#

    • If repository issues occur:
      sudo yum clean all
      sudo yum makecache
    • For SELinux-related issues:
      sudo setenforce 0  # Temporarily disable SELinux

    Windows#

    Using MSI Installer#

    1. Download the MSI installer from the MongoDB Download Center

      • Select Windows as your platform
      • Choose «msi» as the package format
    2. Run the installer:

      • Double-click the downloaded MSI file
      • Follow the installation wizard
      • Select the «Complete» installation type
      • Complete the installation
    3. Verify installation by opening Command Prompt and typing:

      mongosh --version

    Chocolatey#

    1. Install Chocolatey (if not already installed), in PowerShell (Admin):

      Set-ExecutionPolicy Bypass -Scope Process -Force
      [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
      iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
    2. Install MongoDB Shell:

      choco install mongodb-shell

    3. Verify installation:

      mongosh --version

    Troubleshooting on Windows#

    • If ‘mongosh’ command isn’t recognized:
      1. Open Environment Variables (search «environment variables» in Start menu)
      2. Under System variables, edit PATH
      3. Add the bin directory (usually C:\Program Files\mongosh\bin)
      4. Restart Command Prompt

    Connecting to a MongoDB Server#

    After installing mongosh, connect to a MongoDB server with:

    mongosh "mongodb://hostname:27017"

    Or with authentication:

    mongosh "mongodb://username:password@hostname:27017/database"

    For MongoDB Atlas:

    mongosh "mongodb+srv://username:password@cluster.mongodb.net/database"

    Using MongoDB Shell Configuration File#

    You can create a mongosh configuration file to customize your experience:

    1. Create a .mongoshrc.js file:

      • On macOS/Linux: ~/.mongoshrc.js
      • On Windows: %USERPROFILE%\.mongoshrc.js
    2. Add custom configurations, for example:

      // Custom prompt
      prompt = () => {
        return `${db.getName()} > `;
      };
      
      // Custom helper function
      function countDocs(collection) {
        return db[collection].countDocuments();
      }

    For more information, visit the official MongoDB Shell documentation.

    Table of Contents

    1. Introduction
    2. Prerequisites
    3. Installing on Windows
      1. Using the MongoDB Installer Package
      2. Installing via Chocolatey
    4. Installing on Mac
      1. Using the MongoDB Installer Package
      2. Installing via Homebrew
    5. Installing on Ubuntu
      1. Using the Official MongoDB Repository
    6. Verifying Your Installation
    7. Connecting to a MongoDB Database
    8. Conclusion

    Introduction

    Installing the MongoDB Shell (mongosh) is the first step many developers take towards interacting with MongoDB, a popular NoSQL database. Mongosh allows you to create, read, update, and delete data within your MongoDB instance, as well as manage the database configuration. In this guide, we will walk through the installation process for mongosh on Windows, Mac, and Ubuntu systems, covering different installation methods and tips for a smooth setup.

    Prerequisites

    Before installing mongosh, ensure that you have the following:

    • Network connectivity to download mongosh from the internet.
    • Administrative access to your computer (especially for Windows).
    • Basic knowledge of terminal (or command prompt) commands.

    Installing on Windows

    Using the MongoDB Installer Package

    To install mongosh on Windows:

    1. Visit the official MongoDB download page for mongosh.
    2. Select the latest version and download the Windows (.msi) installer.
    3. Run the installer and follow the instructions to install mongosh on your system.
    4. Once installed, you can open mongosh by searching for it in the Start menu, or by running mongosh in the Command Prompt.

    Installing via Chocolatey

    If you prefer package managers, you can install mongosh using Chocolatey:

    
    choco install mongodb-shell
      

    After the installation completes, run mongosh in Command Prompt to confirm the installation.

    Installing on Mac

    Using the MongoDB Installer Package

    For Mac users:

    1. Go to the mongosh download page and download the macOS (.pkg) installer.
    2. Open the downloaded package and follow the installer’s instructions.
    3. Once installed, open a terminal and run mongosh to start the MongoDB shell.

    Installing via Homebrew

    You can also use Homebrew by running:

    
    brew install mongodb/brew/mongodb-community-shell
     

    This will install mongosh as well as the necessary dependencies. To launch, type mongosh in your terminal.

    Installing on Ubuntu

    Using the Official MongoDB Repository

    To install on Ubuntu:

    Step 1: Import the MongoDB public key:

    
    wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
    

    Step 2: Add the MongoDB repository:

    
    echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
      

    Step 3: Update the local package database:

    
    sudo apt-get update
      

    Step 4: Install mongosh:

    
    sudo apt-get install -y mongodb-mongosh
      

    Finally, verify the installation by running mongosh in your terminal.

    Verifying Your Installation

    Regardless of the operating system, once mongosh is installed, you can verify it by running:

    
    mongosh --version
      

    This command should return the version of mongosh that is currently installed on your system. It ensures that mongosh has been installed correctly and that it’s accessible from the terminal or command line.

    Connecting to a MongoDB Database

    After installing mongosh, you can connect to your MongoDB database with the following command:

    
    mongosh "mongodb://localhost:27017/mydb"
      

    Replace “localhost:27017” with the address of your MongoDB server and “mydb” with the name of the database you want to interact with.

    Conclusion

    With mongosh installed, you are now ready to explore and manage your MongoDB databases across any of these platforms. Installation is just the beginning, now dive into the world of MongoDB operations and queries to take full advantage of your database system.

    To use the MongoDB Shell, you must have a MongoDB deployment to connect
    to.

    • For a free cloud-hosted deployment, you can use
      MongoDB Atlas.

    • To learn how to run a local MongoDB deployment, see
      Install MongoDB.

    You can use the MongoDB Shell to connect to MongoDB version 4.2 or
    greater.

    You can install MongoDB Shell 2.0.0 on these operating systems:

    Operating System

    Supported Versions

    macOS

    11+ (x64 and ARM64)

    Microsoft Windows

    Microsoft Windows Server 2016+

    Microsoft Windows 10+

    Linux

    Red Hat Enterprise Linux (RHEL) 8+ (x64, ARM64, ppc64le, and s390x)

    Ubuntu 20.04+ (x64 and ARM64)

    Amazon Linux 2023 (x64 and ARM64)

    Amazon Linux 2 (x64 and ARM64)

    Debian 11+

    SLES 15

    Oracle Linux 8+ running the Red Hat Compatible Kernel (RHCK). MongoDB Shell does not support the Unbreakable Enterprise Kernel (UEK).

    Starting in mongosh 2.0.0:

    • Amazon Linux 1, Debian 9, and macOS 10.14 aren’t supported.

    • Red Hat Enterprise Linux (RHEL) 7, Amazon Linux 2, SUSE Linux
      Enterprise Server (SLES) 12, and Ubuntu 18.04 support is deprecated
      and might be removed in a later mongosh release.

    Select the appropriate tab for your operating system:

    Note

    On Windows, mongosh preferences and configuration options
    are stored in the %APPDATA%/mongodb/mongosh directory.

    Open a cmd terminal and run the following command from the
    directory that has the mongosh .zip archive:

    tar -xf mongosh-2.4.0-win32-x64.zip

    The extracted archive has a bin folder that contains two files,
    mongosh.exe and mongosh_crypt_v1.dll.

    Ensure that the extracted MongoDB Shell binary is in the desired
    location in your filesystem, then add that location to your PATH
    environment variable.

    To add the MongoDB Shell binary’s location to your
    PATH environment variable:

    1. Open the Control Panel.

    2. In the System and Security category, click
      System.

    3. Click Advanced system settings. The System
      Properties
      modal displays.

    4. Click Environment Variables.

    5. In the System variables section, select Path and click
      Edit. The Edit environment variable modal
      displays.

    6. Click New and add the filepath to your mongosh
      binary.

    7. Click OK to confirm your changes. On each other
      modal, click OK to confirm your changes.

    To confirm that your PATH environment variable is correctly
    configured to find mongosh, open a command prompt and enter the
    mongosh --help command. If your PATH is configured
    correctly, a list of valid commands displays.

    Important

    To view the complete list of system requirements for Homebrew,
    see the
    Homebrew Website.

    The Homebrew package manager is the recommended installation
    method for mongosh on macOS. To learn how to manually
    install mongosh from an archive instead, see
    Install from .zip File.

    mongosh installed with Homebrew does not support
    automatic client-side field level encryption.

    To install mongosh with Homebrew:

    Refer to the Homebrew website
    for the steps to install Homebrew on macOS.

    Issue the following command from the terminal to install the
    mongosh package:

    To manually install mongosh using a downloaded .zip
    file:

    Download the appropriate version of mongosh for your operating
    system. MongoDB provides versions of mongosh for Intel and ARM
    architectures.

    Go to the directory that contains the mongosh .zip archive,
    then unpack the .zip file.

    If your computer is Intel based, run:

    unzip mongosh-2.4.0-darwin-x64.zip

    If your computer is ARM based (M1 or M2), run:

    unzip mongosh-2.4.0-darwin-arm64.zip

    The extracted archive has a bin folder that contains two files,
    mongosh and mongosh_crypt_v1.dylib.

    If your web browser automatically extracts the archive as part of the
    download, or if you extract the archive without using the unzip
    command, you may need to make the binary executable.

    To make the binary executable, run the following command in the
    directory where you extracted the archive:

    You can either:

    • Copy the mongosh binary into a directory listed in your
      PATH variable, such as /usr/local/bin. Run the following
      commands from the directory where you extracted the download file:

      sudo cp mongosh /usr/local/bin/
      sudo cp mongosh_crypt_v1.so /usr/local/lib/
    • Create symbolic links to the MongoDB Shell. Switch to the
      directory where you extracted the files from the .tgz archive.
      Run the following command to create links to a directory already
      in your PATH such as /usr/local/bin.

      sudo ln -s $(pwd)/bin/* /usr/local/bin/

    macOS may prevent mongosh from running after installation. If
    you receive a security error when starting mongosh indicating
    that the developer could not be identified or verified, perform
    the following actions:

    1. Open System Preferences.

    2. Select the Security and Privacy pane.

    3. Under the General tab, click the button to the right of the
      message about mongosh, labelled either Open Anyway
      or Allow Anyway depending on your version of macOS.

    Select the appropriate tab based on your Linux distribution and
    desired package from the tabs below:

    • To install the .deb package on Ubuntu 22.04 (Jammy), Ubuntu
      20.04 (Focal), Ubuntu 18.04 (Bionic), or Debian, click the
      .deb tab.

    • To install the .rpm package on
      RHEL, Amazon Linux 2023, or Amazon
      Linux 2, click the .rpm tab.

    • To install the .tgz tarball, click the .tgz tab.

    mongosh is available as a PPA for the following platforms:

    • Ubuntu 24.04 (Noble Numbat)

    • Ubuntu 22.04 (Jammy)

    • Ubuntu 20.04 (Focal)

    • Ubuntu 18.04 (Bionic)

    From a terminal, issue the following command to import the
    MongoDB public GPG key from https://www.mongodb.org/static/pgp/server-8.0.asc:

    wget -qO- https://www.mongodb.org/static/pgp/server-8.0.asc | sudo tee /etc/apt/trusted.gpg.d/server-8.0.asc

    The previous command writes the GPG key to your system’s
    /etc/apt/trusted.gpg.d folder and prints the key to your
    terminal. You do not need to copy or save the key that is printed to
    the terminal.

    If you receive an error indicating that gnupg is not installed,
    perform the following steps:

    1. Install gnupg and its required libraries using the following command:

      sudo apt-get install gnupg

    2. Retry importing the key:

      wget -qO- https://www.mongodb.org/static/pgp/server-8.0.asc | sudo tee /etc/apt/trusted.gpg.d/server-8.0.asc

    Create the list file
    /etc/apt/sources.list.d/mongodb-org-8.0.list for your
    version of Ubuntu.

    Click on the appropriate tab for your version of Ubuntu.
    If you are unsure of what Ubuntu version the host is running,
    open a terminal or shell on the host and run lsb_release -dc.

    The following instruction is for Ubuntu 24.04 (Noble Numbat).
    For other Ubuntu releases, click the appropriate tab.

    Create the
    /etc/apt/sources.list.d/mongodb-org-8.0.list
    file for Ubuntu 24.04 (Noble Numbat):

    echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list

    The following instruction is for Ubuntu 22.04 (Jammy).
    For other Ubuntu releases, click the appropriate tab.

    Create the
    /etc/apt/sources.list.d/mongodb-org-8.0.list
    file for Ubuntu 22.04 (Jammy):

    echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/8.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list

    The following instruction is for Ubuntu 20.04 (Focal).
    For other Ubuntu releases, click the appropriate tab.

    Create the
    /etc/apt/sources.list.d/mongodb-org-8.0.list
    file for Ubuntu 20.04 (Focal):

    echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/8.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list

    The following instruction is for Ubuntu 18.04
    (Bionic)
    . For other Ubuntu releases, click the
    appropriate tab.

    Create the
    /etc/apt/sources.list.d/mongodb-org-8.0.list
    file for Ubuntu 18.04 (Bionic):

    echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/8.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list

    Issue the following command to reload the local package database:

    mongosh supports OpenSSL. You can also configure mongosh to use
    your system’s OpenSSL installation.

    To install the latest stable version of mongosh with the included
    OpenSSL libraries:

    sudo apt-get install -y mongodb-mongosh

    To install mongosh with your OpenSSL 1.1 libraries:

    sudo apt-get install -y mongodb-mongosh-shared-openssl11

    To install mongosh with your OpenSSL 3.0 libraries:

    sudo apt-get install -y mongodb-mongosh-shared-openssl3

    To confirm that mongosh installed successfully, run the following
    command:

    Your terminal should respond with the version of mongosh you have
    installed.

    mongosh is available as yum package for the
    following platforms:

    • RHEL

    • Amazon Linux 2023

    • Amazon Linux 2

    Create a /etc/yum.repos.d/mongodb-org-8.0.repo file so that
    you can install mongosh directly using yum.

    There are .rpm distributions for RHEL and Amazon Linux.

    • Choose the tab to select the file for your distribution.

    • Copy the contents of the tab.

    • Paste the contents into the .repo file.

    [mongodb-org-8.0]
    name=MongoDB Repository
    baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/8.0/$basearch/
    gpgcheck=1
    enabled=1
    gpgkey=https://www.mongodb.org/static/pgp/server-8.0.asc

    You can also download the .rpm files directly from the
    MongoDB repository.
    Downloads are organized in the following order:

    1. Red Hat or CentOS version (for example, 8)

    2. MongoDB edition (for example, mongodb-enterprise)

    3. MongoDB release version
      (for example, 8.0)

    4. Architecture (for example, x86_64)

    [mongodb-org-8.0]
    name=MongoDB Repository
    baseurl=https://repo.mongodb.org/yum/amazon/2023/mongodb-org/8.0/$basearch/
    gpgcheck=1
    enabled=1
    gpgkey=https://www.mongodb.org/static/pgp/server-8.0.asc

    Note

    If your system uses Amazon Linux 2, replace 2023 with
    2 in the baseurl.

    You can also download the .rpm files directly from the
    MongoDB repository. Downloads are
    organized in the following order:

    1. Amazon Linux version (for example, 2023)

    2. MongoDB release version
      (for example, 8.0)

    3. Architecture (for example, x86_64)

    mongosh supports OpenSSL. You can also configure mongosh to use
    your system’s OpenSSL installation.

    To install the latest stable version of mongosh with the included
    OpenSSL libraries:

    sudo yum install -y mongodb-mongosh

    To install mongosh with your OpenSSL 1.1 libraries:

    sudo yum install -y mongodb-mongosh-shared-openssl11

    To install mongosh with your OpenSSL 3.0 libraries:

    sudo yum install -y mongodb-mongosh-shared-openssl3

    Download the appropriate version of mongosh for your operating
    system. MongoDB also provides versions of mongosh that use your
    system’s OpenSSL installation.

    See the MongoDB Download Center.

    Go to the directory that contains the .tgz archive, then unpack
    the archive.

    The name of the .tgz package varies depending on the version you
    downloaded. Replace the .tgz package name in the following
    command with the name of the package you downloaded and run the
    command.

    tar -zxvf mongosh-2.4.0-linux-x64.tgz

    The extracted archive has a bin folder that contains two files,
    mongosh and mongosh_crypt_v1.so.

    If your web browser automatically extracts the archive as part of the
    download, or if you extract the archive without using the tar
    command, you may need to make the binary executable.

    To make the binary executable, run the following command in the
    directory where you extracted the archive:

    You can either:

    • Copy the mongosh binary into a directory listed in your
      PATH variable, such as /usr/local/bin. Run the following
      commands from the directory where you extracted the download file:

      sudo cp mongosh /usr/local/bin/
      sudo cp mongosh_crypt_v1.so /usr/local/lib/
    • Create symbolic links to the MongoDB Shell. Switch to the
      directory where you extracted the files from the .tgz archive.
      Run the following command to create links to a directory already
      in your PATH such as /usr/local/bin.

      sudo ln -s $(pwd)/bin/* /usr/local/bin/

    Once you successfully install mongosh, learn how to
    connect to your MongoDB deployment.

    MongoDB provides a programmatically accessible list of mongosh
    downloads that
    can be accessed through your application.

    mongosh

    Evergreen Waterfall CI

    The MongoDB Shell

    This repository is a monorepo for all the various components in the MongoDB Shell across
    all environments (REPL, Browser, Compass, etc).

    For our official documentation, please visit MongoDB Docs
    page.

    MongoDB Shell works with MongoDB servers >= 4.0.

    MongoDB Shell Example

    Installation

    You can get the release tarball from our Downloads
    Page. We currently maintain MongoDB
    Shell on three different platforms — Windows (zip), MacOS (zip) and Linux (tgz, deb and rpm).
    Once downloaded, you will have to extract the binary and add it to your PATH
    variable. For detailed instructions for each of our supported platforms, please visit
    installation documentation.

    CLI Usage

      $ mongosh [options] [db address] [file names (ending in .js or .mongodb)]
    
      Options:
    
        -h, --help                                 Show this usage information
        -f, --file [arg]                           Load the specified mongosh script
            --host [arg]                           Server to connect to
            --port [arg]                           Port to connect to
            --build-info                           Show build information
            --version                              Show version information
            --quiet                                Silence output from the shell during the connection process
            --shell                                Run the shell after executing files
            --nodb                                 Don't connect to mongod on startup - no 'db address' [arg] expected
            --norc                                 Will not run the '.mongoshrc.js' file on start up
            --eval [arg]                           Evaluate javascript
            --json[=canonical|relaxed]             Print result of --eval as Extended JSON, including errors
            --retryWrites[=true|false]             Automatically retry write operations upon transient network errors (Default: true)
    
      Authentication Options:
    
        -u, --username [arg]                       Username for authentication
        -p, --password [arg]                       Password for authentication
            --authenticationDatabase [arg]         User source (defaults to dbname)
            --authenticationMechanism [arg]        Authentication mechanism
            --awsIamSessionToken [arg]             AWS IAM Temporary Session Token ID
            --gssapiServiceName [arg]              Service name to use when authenticating using GSSAPI/Kerberos
            --sspiHostnameCanonicalization [arg]   Specify the SSPI hostname canonicalization (none or forward, available on Windows)
            --sspiRealmOverride [arg]              Specify the SSPI server realm (available on Windows)
    
      TLS Options:
    
            --tls                                  Use TLS for all connections
            --tlsCertificateKeyFile [arg]          PEM certificate/key file for TLS
            --tlsCertificateKeyFilePassword [arg]  Password for key in PEM file for TLS
            --tlsCAFile [arg]                      Certificate Authority file for TLS
            --tlsAllowInvalidHostnames             Allow connections to servers with non-matching hostnames
            --tlsAllowInvalidCertificates          Allow connections to servers with invalid certificates
            --tlsCertificateSelector [arg]         TLS Certificate in system store (Windows and macOS only)
            --tlsCRLFile [arg]                     Specifies the .pem file that contains the Certificate Revocation List
            --tlsDisabledProtocols [arg]           Comma separated list of TLS protocols to disable [TLS1_0,TLS1_1,TLS1_2]
            --tlsFIPSMode                          Enable the system TLS library's FIPS mode
    
      API version options:
    
            --apiVersion [arg]                     Specifies the API version to connect with
            --apiStrict                            Use strict API version mode
            --apiDeprecationErrors                 Fail deprecated commands for the specified API version
    
      FLE Options:
    
            --awsAccessKeyId [arg]                 AWS Access Key for FLE Amazon KMS
            --awsSecretAccessKey [arg]             AWS Secret Key for FLE Amazon KMS
            --awsSessionToken [arg]                Optional AWS Session Token ID
            --keyVaultNamespace [arg]              database.collection to store encrypted FLE parameters
            --kmsURL [arg]                         Test parameter to override the URL of the KMS endpoint
    
      OIDC auth options:
    
            --oidcFlows[=auth-code,device-auth]    Supported OIDC auth flows
            --oidcRedirectUri[=url]                Local auth code flow redirect URL [http://localhost:27097/redirect]
            --oidcTrustedEndpoint                  Treat the cluster/database mongosh as a trusted endpoint
            --oidcIdTokenAsAccessToken             Use ID tokens in place of access tokens for auth
            --oidcDumpTokens[=mode]                Debug OIDC by printing tokens to mongosh's output [redacted|include-secrets]
            --oidcNoNonce                          Don't send a nonce argument in the OIDC auth request
    
      DB Address Examples:
    
            foo                                    Foo database on local machine
            192.168.0.5/foo                        Foo database on 192.168.0.5 machine
            192.168.0.5:9999/foo                   Foo database on 192.168.0.5 machine on port 9999
            mongodb://192.168.0.5:9999/foo         Connection string URI can also be used
    
      File Names:
    
            A list of files to run. Files must end in .js and will exit after unless --shell is specified.
    
      Examples:
    
            Start mongosh using 'ships' database on specified connection string:
            $ mongosh mongodb://192.168.0.5:9999/ships
    
      For more information on usage: https://docs.mongodb.com/mongodb-shell.

    Local Development

    Requirements

    • Node.js v20.x

    Install

    npm run bootstrap
    npm run compile-cli

    Running Tests

    Run all tests (this may take some time):

    Run tests from a specific package:

    npm -w @mongosh/cli-repl run test

    To test against a specific version, the MONGOSH_SERVER_TEST_VERSION
    environment variable can be set to a semver string specifying a server version,
    e.g. MONGOSH_SERVER_TEST_VERSION='>= 7.0.0-rc0' npm -w @mongosh/cli-repl run test.

    Starting the CLI

    Via npm:

    npm run start <... connection string, CLI args, etc.>

    This will compile all Typescript dependencies of the CLI package first.

    Alternatively you can also run start inside the cli-repl package, if you’re
    sure everything else is compiled:

    npm run -w @mongosh/cli-repl start <... connection string, CLI args, etc.>

    Compiling

    Compile all Typescript:

    Compile just the CLI ands its dependencies:

    Compile the standalone executable (this may take some time):

    Relevant environment variables for compiling are:

    • NODE_JS_VERSION: Specify a Node.js version to use for compilation, e.g. 16.15.0 or 16.x
    • BOXEDNODE_CONFIGURE_ARGS: Node.js configure flags as a comma-separated list
      or JSON array, e.g. --shared-openssl,--shared-zlib
    • BOXEDNODE_MAKE_ARGS: Node.js make args (no distinction from BOXEDNODE_CONFIGURE_ARGS on Windows)
      as a comma-separated list or JSON array, e.g. -j12

    Compile a specific package, e.g. the .deb for Debian:

    npm run compile-exec
    npm run evergreen-release package -- --build-variant=deb-x64

    Compilation and packaging output is written to dist/.

    Releasing

    Refer to the build package documentation.

    Contributing

    For issues, please create a ticket in our
    JIRA Project.

    For contributing, please refer to CONTRIBUTING.md.

    Is there anything else you’d like to see in MongoDB Shell? Let us know by
    submitting suggestions in our feedback
    forum.

    License

    Apache-2.0

    Понравилась статья? Поделить с друзьями:
    0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии
  • Windows server 2003 установка iis
  • Installation windows 10 pro
  • Lexmark mx421 драйвер windows xp
  • Stikynot для windows 10
  • Запуск windows xp mode windows 7