Installation of Mongosh for MongoDB Atlas on the cloud

Can Mongosh be installed on a MacOS High Sierra 10.13.6 ?

I have been following W3Schools MongoDB Getting Started for the installation, where I have setup the MongoDB Atlas cloud database platform with a 512MB shared cluster and added my current IP address along with having the default cloud IP address .

W3Schools is using mongosh version 1.3.1 for the tutorial.

I have created a mongodb-learning repository.

On my zsh command line, in my new W3Schools-MongoDB project folder, I have tried to use brew install mongosh , as well as brew install mongosh@1.3.1 , but each time when I check if mongosh is installed with mongosh --version, it says zsh: command not found: mongosh.

I just want to get an understanding on how the Shell works with MongoDB Atlas cloud ?

I have Visual Studio Code version 1.78.2 with OS: Darwin x64 17.7.0.

I am a bit confused with the differences of how local and the cloud side works.
For the cloud setup that W3Schools recommended, does the database creation happen in an editor like my Visual Studio Code and the result shown on the server, whereas with local can you view result on your own localhost setup ?

As well as mongosh, I also tried to install MongoDB for VSCode v 0.11.1 Extension in my project folder, connecting with a connection string, but that was taking a long time to install for some reason, so I abandoned that.

Looking for help, so that I can get the best setup for my laptop and learn MongoDB from W3Schools tutorial.

If anyone has any ideas on how I can make this work, then your ideas will be much appreciated thanks.

Brew puts mongosh in /usr/local/Cellar/mongosh/1.8.2/bin/mongosh and softlinks to /usr/local/bin/mongosh … if you don’t have /usr/local/bin in your zsh $PATH it won’t be found.

I have put this path in my .zshrc file.

export PATH=“/usr/local/bin/mongosh/:$PATH”

But when I go back to my zsh command line, I am still getting zsh: command not found: mongosh

When you use
brew install mongosh
I assume that this installs the latest version of Mongosh (MongoDB Shell) .

Is there a way to install a particular version of mongosh ?

W3Schools uses version 1.3.1 for mongosh.
I just wonder if I am better off installing that version with my MacOS High Sierra, as it may work better than the newer version on my laptop.

This is incorrect. The PATH export points to a colon-separated list of directories, not to individual programs.
export PATH=“/usr/local/bin:$PATH” is what you want.

I have tried changing to
export PATH=“/usr/local/bin:$PATH”
Mongosh Version not showing

at the bottom of my .zshrc file , but when I type mongosh --version on my command line I am still getting zsh: command not found: mongosh.

I do have an export path for MAMP used with my content Management System up the top of my .zshrc file, but that shouldn’t interfer with the path for mongosh would it ?

I have a MacOS High Sierra 10.13.6, can that be compatible with installing mongosh through brew ?

If mongosh installed at all, it should be compatible.
Your previous path statement is overridden or subsumed by any subsequent path statement.
If you have found the mongosh executable somewhere on your disk, try invoking mongosh via the fully qualified path, e.g., if you know it’s there as /usr/local/bin/mongosh, try /usr/local/bin/mongosh --version and see if it works.
Also, check if the executable bit is correctly set on the file if you find it and it still doesn’t work.

1 Like

Hi Jack

Thanks for your help so far.

I have checked on my zsh command line for location of mongosh installation in 2 places.

In my /usr/local/Cellar folder I could not find mongosh
Mongosh not in Cellar Folder

and also, I could not find mongosh in my /usr/local/bin folder as well.

This makes me think that maybe the installation did not work.

I assume that brew install mongosh would give you the same version 1.8.2 as the download link MongoDB Shell Download | MongoDB. I had noticed in that link that the lowest supported version is MacOS 64 bit (10.14) for version 1.8.2

Is there a way that I can install a lower version of mongosh, so that it can work with my MacOS 10.13.6 ?
W3Schools uses mongosh version 1.3.1 and maybe if I use a slightly lower version then I may get the shell working OK.

brew install package@<version> e.g., brew install mongosh@1.2.3

Please provide output of the commands:
brew install mongosh and brew list mongosh
In my case, it is:

/opt/homebrew/Cellar/mongosh/1.9.0/bin/mongosh
/opt/homebrew/Cellar/mongosh/1.9.0/libexec/bin/mongosh
/opt/homebrew/Cellar/mongosh/1.9.0/libexec/lib/ (9360 files)
% ls -ld /opt/homebrew/bin/mongosh
lrwxr-xr-x  1 me  admin  35 May 18 10:04 /opt/homebrew/bin/mongosh -> ../Cellar/mongosh/1.9.0/bin/mongosh

Well, there you have it.

Does the command

/opt/homebrew/Cellar/mongosh/1.9.0/bin/mongosh

succeed?

Hi rafi

Thanks for your reply

As I mentioned above in my question, I am following through W3Schools MongoDB Getting Started and they are using Mongosh version 1.3.1.

So first off I have run the brew install and brew list commands for Mongosh version 1.3.1 on my MacOS High Sierra 10.13.6.
This is the output I have on the screenshot below.

Brew list gives
Error: No such keg: /usr/local/Cellar/mongosh

and there seems to be an issue with 10 outdated formulae installed even though it looks like it has updated homebrew from 4.0.17 to 4.0.18.
It also looks like it is having problems finding Mongosh 1.3.1 version.

In my next reply, I have installed the latest version that shows how my laptop reacts to a normal install of Mongosh.

Rafi

This is how my MacOs High Sierra 10.13.6 reacts to a normal brew install mongosh and brew list mongosh.

It has a warning that I am using macOS 10.13 and also says to install GNU Complier Collect with brew install gcc.
You can also notice that sqlite and libnghttp2 have installed in Cellar directory.

When I use brew install gcc this is what happens below.


Again, it has a warning that I am using macOS 10.13 and has an error about it at the end as well.
So it seems like it hasn’t installed completely or it hasn’t bundled the whole mongosh together in a mongosh folder like I believe it should do, when using brew install mongosh.

I think moving forward , I just have to work out how I can get the Mongosh shell working with version 1.3.1 that W3Schools has, as that looks to be the version that may work OK on my MacOS High Sierra 10.13.6.

Maybe good alternative in this case as you dont want to upgrade OS is to run mongosh as a docker container assuming you can start docker on your Macos.

Hi rafi

First of all I want to look and see if it is possible to install W3Schools version 1.3.1 of Mongosh on my MacOS High Sierra 10.13.6 .
On my top screenshot, when I used brew install mongosh@1.3.1,
it mentioned You have 10 outdated formulae installed
and had a warning: No available formula with the name "mongosh@1.3.1". Do you mean Mongosh ?
so, I just wonder if there is a way to get around this, to make it work ?

The Mac operating system I have, has very important web learning stuff on it, so I feel that I need to do a backup and tread very carefully before I do an upgrade. With Technology updating, I most likely will have to upgrade at some stage, but I will have to be very careful about it.

I have also seen that you can get a MongoDB for VSCode Extension.
Can that be used when I have a MongoDB Atlas cloud database platform with a 512MB shared cluster ?
Does the extension have to work with the shell ?

I will look into running mongosh as a docker container if all of what I have mentioned above does not work.

mongosh depends on Node.js and even if version 1.3.1 was using Node 14 instead of Node 16 I don’t believe that will run on OSX 10.13.

Docker is definitely an option you have, assuming you can get a Docker version that runs on OSX 10.13.

MongoDB for VS Code is also an alternative you have and it will work with any MongoDB, including the free tier cluster in Atlas. The extension does not need the shell to be installed to work, except for the functionality that lets you launch a shell. If you are running VS Code 1.78 as you mentioned above then you should be able to install the most recent version of the extension.

Hi Massimiliano

I have a Node Version Manager setup on my MacOS 10.13.6.
I have the alias default set to Node version 16.15.0 and I also have an older 8.11.3 Node version.

I just wonder if having the correct Node version running on my Mac for Mongosh 1.3.1, will be the key to getting the shell running.
It is just a matter of finding out what Node version I can install that may make it work with Mongosh 1.3.1.

From my previous reply, I mentioned that brew install mongosh@1.3.1 gave me 10 outdated formulae installed and a warning: No available formula with the name "mongosh@1.3.1". Do you mean Mongosh ?
, as can be seen in screenshot below.

Would having it working with the correct Node version, fix this issue and make it work on my Mac ?

It would be good if I can get MongoDB shell working with Mongosh version 1.3.1 ,
but if I can’t, I will look into seeing how I can get the Docker or MongoDB for VSCode Extension options working.

Hi @Massimiliano_Marcon

I have had a break finishing my Mongosh setup , as I became frustrated with it and so I went on to learn Django.

Now I feel a bit more refreshed and just want to get an understanding on why I have not been able to get Mongosh working.

Back in June I had installed Node Version 14.19.1 using nvm, as I found from screenshot shown below, that this the Node Version that runs with Mongosh 1.3.1 , I have been trying to get working.

I have a MacOS High Sierra 10.13.6.

Below I have a screenshot showing myself using brew install v1.3.1 for Mongosh after I had installed Node version 14.19.1

As you can see from the screenshot I am using brew install v1.3.1.
: it initially did an auto- update of homebrew to 4.0.22
: Update 3 taps and showed new formulae and casks
: It said that I have 15 outdated formulae installed.
: It shows website for where changelog 4.0.22 can be found
: It has a warning saying no available formula with name v1.3.1 and it cannot find it.

How do I get this to work, with the correct formulas and casks to be run with Mongosh 1.3.1 on my Mac OS 10.13.6, with Node 14.19.1 ?
Or is this not possible to do with my Mac Operating System ?

The current version of mongosh is 1.10.3 … I see your ostensible use case, but I think the world has moved on. You may not get much help around here for backlevel stuff. Maybe StackExchange?