DeveloperBreeze

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.

Continue Reading

Discover more amazing content handpicked just for you

Tutorial

How to Install MongoDB on Ubuntu

To ensure that MongoDB starts automatically on system boot, enable the MongoDB service:

sudo systemctl enable mongod

Oct 18, 2024
Read More

Discussion 0

Please sign in to join the discussion.

No comments yet. Start the discussion!