Install ONLY mongo shell, not mongodb
MongodbShellRhelMongodb 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
- 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 <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.
-
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
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
:
- 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.