Install ONLY mongo shell, not mongodb

MongodbShellRhel

Mongodb Problem Overview


As mentioned above, I need to install only the mongo shell on a RHEL instance (machine A). I have a mongodb server on a separate instance (machine B) and need to connect to that from A to run mongodump and mongorestore commands.

I tried looking it up on the web but all I got was instructions to install the complete mongodb package.

Any help appreciated.

Mongodb Solutions


Solution 1 - Mongodb

Official documentation says that you should be fine installing mongodb-org-shell only.

Solution 2 - Mongodb

  1. Create a repository file at sudo vim /etc/yum.repos.d/mongodb.repo

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

  1. sudo yum clean all

  2. sudo yum install mongodb-org-shell-4.0.2

  3. mongo <mongo-server-ip> Note: Step 4 will not work in all cases. You need to check proper command to connect to remote mongo server.

Source: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/

Solution 3 - Mongodb

You can follow the official tutorial on installing mongodb, and instead of installing the main package that will install all the packages, just install the package containing mongoshell

Solution 4 - Mongodb

Please follow below steps.

  1. Create a file /etc/yum.repos.d/mongodb.repo

  2. Update the above file to contain:

     [mongodb]
     name=MongoDB Repository  
     baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/  
     gpgcheck=0
     enabled=1
    
  3. sudo yum install -y mongodb-org-shell-2.6.9

  4. mongo mongo-db_server_IP:27017/database_name -u username -p password

Solution 5 - Mongodb

You might want to install mongosh (MongoDB Shell) instead. The legacy mongo shell has been deprecated since MongoDB v5.0 and replaced by mongosh. From the mongosh docs:

> The new MongoDB Shell, mongosh, offers numerous advantages over the > legacy mongo shell, such as: > > - Improved syntax highlighting. > - Improved command history. > - Improved logging. > > Currently mongosh supports a subset of the mongo shell > methods. Achieving feature parity between mongosh and the mongo shell > is an ongoing effort. > > To maintain backwards compatibility, the methods that mongosh supports > use the same syntax as the corresponding methods in the mongo shell. > To see the complete list of methods supported by mongosh, see MongoDB > Shell Methods.

Further reference: Compatibility Changes with Legacy mongo Shell

Solution 6 - Mongodb

Head to Mongo download page; download your required package regarding your operating system. Finally follow the instruction of your operating system to install the package.

Especially to install mongo or mongosh:

  1. download .tgz file and untar the file into /usr/local/
  2. add /usr/local/mongo/ into the shell profile (e.g. ~/.bashrc) and restart your terminal

For more information read the docs.

P.S.: mongo in the path should be vary based on the version of the downloaded package.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRijumoneView Question on Stackoverflow
Solution 1 - MongodbPinkFluffyUnicornView Answer on Stackoverflow
Solution 2 - MongodbketankkView Answer on Stackoverflow
Solution 3 - MongodbMansuroView Answer on Stackoverflow
Solution 4 - Mongodber.roshanView Answer on Stackoverflow
Solution 5 - MongodbabcoepView Answer on Stackoverflow
Solution 6 - MongodbEsmaeil MIRZAEEView Answer on Stackoverflow