ChatGPT解决这个技术问题 Extra ChatGPT

只安装 mongo shell,不安装 mongodb

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.


A
Ali Ben Messaoud

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


Thanks! Not sure how I missed that!
@PinkFluffyUnicorn , If the O.S will be windows then how we install the 'mongo shell' there.
@PinkFluffyUnicorn yes you can install just the client tools on Windows, the docs are a bit confusing. It mentions that you can set those options on the unattended install - but not on the interactive. However, when you run the interactive it gives you the options to limit it to just the client tools.
The package appears to be called mongodb-clients on Ubuntu now
And now it's called 'mongo-tools'
N
Nagy Nick

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

sudo yum clean all sudo yum install mongodb-org-shell-4.0.2 mongo 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/


M
Mansuro

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


Thanks! I am choosing the other answer as correct as it is more explicit on the name of the package.
apologies for the same. Will persevere to be more diligent in the future. :)
B
Brad K.

Please follow below steps.

Create a file /etc/yum.repos.d/mongodb.repo 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 sudo yum install -y mongodb-org-shell-2.6.9 mongo mongo-db_server_IP:27017/database_name -u username -p password


a
abcoep

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


E
Esmaeil MIRZAEE

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:

download .tgz file and untar the file into /usr/local/ 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.