DeveloperBreeze

How to Install MongoDB Shell (mongosh) on Ubuntu

MongoDB has introduced mongosh, a modern command-line shell to interact with MongoDB databases. If you’re on Ubuntu and want to install mongosh, follow these simple steps.

Step 1: Download MongoDB Shell (mongosh)

The MongoDB Shell is available in a compressed tarball. Download it using the following command:

wget https://downloads.mongodb.com/compass/mongosh-1.10.1-linux-x64.tgz

Step 2: Extract the tarball

Extract the contents of the downloaded file using the tar command:

tar -xzvf mongosh-1.10.1-linux-x64.tgz

Step 3: Move the mongosh binary to a system path

Move the mongosh binary to a directory included in your system’s PATH, such as /usr/local/bin/:

sudo mv mongosh-1.10.1-linux-x64/bin/* /usr/local/bin/

This ensures that you can run mongosh from any location in your terminal.

Step 4: Verify the Installation

To confirm that mongosh is installed and properly configured, run the following command to check the version:

mongosh --version

If everything is set up correctly, you should see the version of mongosh that you installed.

Step 5: Connect to Your MongoDB Server

Once installed, you can connect to your MongoDB instance. For a local MongoDB instance, run:

mongosh mongodb://localhost:27017

This will open the MongoDB shell connected to your local database.

Related Posts

More content you might like

Tutorial

How to Install MongoDB on Ubuntu

MongoDB is a popular NoSQL database widely used for modern web applications due to its flexibility and scalability. In this guide, we'll walk through the process of installing MongoDB on an Ubuntu machine. We'll be using MongoDB 6.0 for this installation.

Before installing MongoDB, make sure your system's package list is up to date. Open a terminal and run the following command:

Oct 18, 2024
Read More

Discussion 0

Please sign in to join the discussion.

No comments yet. Be the first to share your thoughts!