Is it possible to install just the mongo Shell?
Question
I have Docker installed and am running a MongoDB
container for my local development on my Mac. The problem is that I can't connect to said DB easily from CLI. I have Robo 3T installed, but I would prefer to use the CLI
client instead.
Is there a known way to install JUST the mongo shell
(command mongo
) and not the full DB distribution on OS X?
Solution
You can use HomeBrew, see the official MongoDB HomeBrew page.
Just add the tap:
brew tap mongodb/brew
And then after adding the tap from above, you can then install the Mongo shell with:
brew install mongodb-community-shell
OTHER TIPS
You can download the latest Mongo Shell for MacOS from the following URL:
https://downloads.mongodb.org/osx/mongodb-shell-osx-ssl-x86_64-3.6.2.tgz
For the sake of completion, the Mongo Shell for Windows is available at https://downloads.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-3.6.2-signed.msi
Furthermore, for other Linux distributions, I suggest you create a MongoDB Atlas cluster (for instance, a free M0 cluster) at www.mongodb.com/atlas where you'll find the Mongo Shell downloads for all OSes in the Connect dialog of your cluster.
I hope this helps.
I don't think so in macOS whitout installation of MongoDB ,you can able to connect mongo shell
.
To install MongoDB Community Edition
on macOS system Install MongoDB Community Edition on macOS You may download MongoDB Community Edition through either the MongoDB Download Center or the popular macOS package manager Homebrew.
As The mongo Shell is an interactive JavaScript interface to MongoDB.
Note: Ensure that
MongoDB
is running before attempting to start themongo
shell.
I understand you have mongo running on Docker, so as a workaround you can use the same running container to connect:
docker exec -ti $container_name bash
bash-4.2$ mongo -u $MONGODB_USER -p $MONGODB_PASSWORD $MONGODB_DATABASE
MongoDB shell version v3.6.3
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.6.3
Ideally you could connect with just one command but I don't know why is failing when calling from outside:
# this fail but you can use with other databases
docker exec -ti $container_name mongo -u $MONGODB_USER -p $MONGODB_PASSWORD $MONGODB_DATABASE
The idea is simple, mongo is installed on the container so you tell docker to run from inside the container. If you need to load files from outside you always can mount a volume.