google cloud platform

How to install only mongo shell client and not mongodb ?

This tutorial guides you to install only mongo shell client without mongodb server. I wanted test mongo instance connection from Cluster A, whereas the mongodb server instance is running Cluster B. Let’s see what Mongo provides to do that.

Install only mongo shell client and not mongodb

If you would like to install only the mongo shell client, MongoDB provides a package called mongodb-org-shell which contains mongo shell. And you may have to install other tools so that you would be able to install mongo shell client correctly.

I would recommend to follow the instructions in MongoDB official documentation if the below steps don’t work for you as the instructions may keep changing.

First, go to the cloud shell and run the following command. This command will download the key and pass it to apt-key add.

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

OK

Then create a package list file for MongoDB by running the following instruction.

$ echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list

deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.2 multiverse

Update the local package database by running the following command.

$ sudo apt-get update

Note, before installing mongo-org-shell you might need to install dependencies. You might face the below error, so make sure that you install libcurl3 before installing mongo shell.

$ sudo apt-get install mongodb-org-shell
----
----
The following packages have unmet dependencies:
 mongodb-org-shell : Depends: libcurl3 (>= 7.16.2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Therefore, install libcurl3 dependency by running the following command.

$ sudo apt-get install libcurl3

Finally, install only mongo shell client i.e., mongo-org-shell.

$ sudo apt-get install mongodb-org-shell

That’s it. You had successfully installed mongo shell client without mongodb server.

Now you can test mongo shell client (only) by running the following command.

$ mongo --host mongodb:27017

Hope it helped 🙂

References

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments