command not found: mongo, after it's installed (OS X) - mongodb

After following official instructions here to install mongo-community, it cannot find the command to start mongo.
Steps I used to install mongo:
brew tap mongodb/brew
brew install mongodb-community#3.6
The installation was successful, but when I tried to start mongo with mongo. This error appears:
zsh: command not found: mongo
Tried the solutions at Mongod: Command Not Found (OS X), none of them worked.
Also, can't seem to find where mongo is located.
Thank in advance!

Add the path to "mongo" to your terminal shell:
export PATH="$PATH:/usr/local/Cellar/mongodb-community#3.6/3.6.14/bin"
(replace version number with your local version)
It cannot find the command since $PATH is not set correctly. After MongoDB moved from open source to community liscence on Oct 16, 2018, the installation path on Mac changed. It's installed in /usr/local/Cellar (reference: Location of the mongodb database on mac).
Thanks to #kevinadi for point out the issue.

mongodb shell reference
In my case I couldn't find mongo command as 2022, so I used mongosh
and it worked fine.

Related

MongoDB won't install on my mac. I installed homebrew in order to install Mongodb but I'm getting some error messages

I used the following command to install mongodb:
my-MBP:~ user$ brew install mongodb:
and this was the output
Error: No available formula with the name "mongodb"
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching for similarly named formulae...
These similarly named formulae were found:
mongodb/brew/mongodb-community mongodb/brew/mongodb-community#3.4
mongodb/brew/mongodb-community-shell mongodb/brew/mongodb-community#3.6
mongodb/brew/mongodb-community#3.2 mongodb/brew/mongodb-community#4.0
To install one of them, run (for example):
brew install mongodb/brew/mongodb-community
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.
This same thing happens why i try to enter "brew install mongo." Is homebrew not installed properly? How specifically can I resolve this issue?**
I would follow the official installation guide, if you haven't already done so:
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/
https://github.com/mongodb/homebrew-brew
To install with brew, you must first:
brew tap mongodb/brew
Then,
brew install <mongodb>
For the input, mongodb doens't appear to be an option. It should be something like mongodb-community#4.2 as shown in the guides.
Hope this helps!

Installing MongoDB with Homebrew

I'm relatively new to MongoDB and am trying to install MongoDB on my Mac with Homebrew, but I'm getting the following error:
Error: No available formula with the name "mongodb"
==> Searching for a previously deleted formula (in the last
month)...
Warning: homebrew/core is shallow clone. To get complete history
run:
git -C "$(brew --repo homebrew/core)" fetch --unshallow
Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.
I ran
brew update
Then
brew install mongodb
Formula mongodb has been removed from homebrew-core. Check pr-43770 from homebrew-core
To our users: if you came here because mongodb stopped working for you, we have removed it from the Homebrew core formulas since it was migrated to a non open-source license.
Fortunately, the team of mongodb is maintaining a custom Homebrew tap. You can uninstall the old mongodb and reinstall the new one from the new tap.
# If you still have the old mongodb installed from homebrew-core
brew services stop mongodb
brew uninstall homebrew/core/mongodb
# Use the migrated distribution from custom tap
brew tap mongodb/brew
brew install mongodb-community
brew services start mongodb-community
Check mongodb/homebrew-brew for more info.
With regards to macOS Big Sur and Homebrew the mongodb documentation states: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/
You should install MongoDB 4.4 Community Edition which supports macOS 10.13 or later, Therefor these steps will be helpful.
SOLUTION 1:
If you have previously installed an older version of the formula, you may encounter a ChecksumMismatchError to fix that:
Remove the downloaded .tgz archive.
brew untap mongodb/brew && brew tap mongodb/brew
Retap the formula.
brew install mongodb-community#4.4
SOLUTION 2:
If you haven't installed any version of the formula.
1, Install the Xcode command-line tools and the Homebrew from https://brew.sh/#install
xcode-select --install
2, Tap the MongoDB Homebrew Tap:
brew tap mongodb/brew
3, Verify installation prerequisites in the macOS Terminal:
brew tap | grep mongodb
4, install MongoDB
brew install mongodb-community#4.4
Note: The installation includes:
• The mongod server,
• The mongos sharded cluster query router,
• The mongo shell
refer to this screenshot:
Finally to run MongoDB (i.e. the mongod process) as a macOS service, issue the following:
brew services start mongodb-community#4.4
screenshot:
first install mongodb
brew tap mongodb/brew
Secondly install using this command. mangodb successfully installed
brew install mongodb-community#4.0
You will get the output
==> CaveatsTo have launchd start mongodb/brew/mongodb-community now and restart at login:
brew services start mongodb/brew/mongodb-community
Or, if you don't want/need a background service you can just run:
mongod --config /usr/local/etc/mongod.conf
==> Summary
🍺 /usr/local/Cellar/mongodb-community/4.2.2: 21 files, 274.5MB, built in 2 minutes 46 seconds
brew services start mongodb/brew/mongodb-community
==> Successfully started `mongodb-community` (label: homebrew.mxcl.mongodb-commu
Try this code in your terminal:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
And then:
brew tap mongodb/brew
Finally:
brew install mongodb-community#4.0
~ % brew services run mongodb-community
/usr/local/opt/mongodb-community/homebrew.mxcl.mongodb-community.plist: service already loaded
Error: Failure while executing
/bin/launchctl bootstrap gui/501 /usr/local/opt/mongodb-community/homebrew.mxcl.mongodb-community.plist
exited with 17.
In MacOs Catalina doesn't work properly for me.
After the installation (https://zellwk.com/blog/install-mongodb/) i had to add permission to "/tmp/mongodb-27017.sock"
sudo chown -R `id -un` /tmp/mongodb-27017.sock
and the command "mongod" seems to ignore the config file (mongod.conf) in "/usr/local/etc" so i have to always launch it with the dbpath argument
mongod --dbpath /usr/local/var/mongodb
even if the same path is specified in the config file.
Also using "mongod" with configuration file doesn't work for me
mongod -f /usr/local/etc/mongod.conf
or
mongod --config /usr/local/etc/mongod.conf
I solved all these issues starting the mongodb via brew services. That worked well without issues and takes the parameters from the right configuration file.
brew services run mongodb-community
Just go for
brew tap mongodb/brew
Homebrew at times won’t get installed in max while the OS is updated , like recently Max OS Ventura - it’s not supported , we can quickly install Mongo DB without homebrew just by using some commands in terminal , checkout the details here : https://medium.com/#pratheushcmohan/install-mongodb-in-mac-without-using-home-brew-23b2556ff930

brew services start mongodb-community#4.0 fails - uninitialized constant

I've followed the directions on the MongoDB docs to install MongoDB on Mac using homebrew:
brew tap mongodb/brew
brew install mongodb-community#4.0
Then I can run it in the foreground using:
mongod --config /usr/local/etc/mongod.conf
But, when trying to start it as a service using:
brew services start mongodb-community#4.0
I get this error:
Error: mongodb-community: uninitialized constant #<Class:0x00007ff189061008>::Gem
I also get this error when running brew doctor:
Warning: Some installed formulae are not readable:
mongodb-community: uninitialized constant #<Class:0x00007ffd903152a0>::Gem
Why this is happening? How do I fix it?
Thank you!
This is an error with the mongodb-community formula. An issue has been filed with the maintainers, a solution found, and a pull request with the fix opened.
In the meantime, you can fix the error yourself. This line in the formula is throwing an exception:
Gem::Version.new(v['version'])
because the Gem class has not been imported. Adding the import:
require 'rubygems'
solves the problem. You can do this locally, by finding and editing the formula on your computer. It is probably in this file:
/usr/local/Homebrew/Library/Taps/mongodb/homebrew-brew/Formula/mongodb-community.rb
Update: A community contributor has fixed this upstream. If you are still experiencing this issue you might need to run brew update
I know it's not correct answer since we are talking about registering service using:
brew services start mongodb-community
But I've SOLVED service registration question this way:
sudo cp /usr/local/Cellar/mongodb-community/4.0.9/homebrew.mxcl.mongodb-community.plist /Library/LaunchAgents/
launchctl load -w /Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist
launchctl start mongodb-community

How to upgrade mongoDB shell version properly on OS X

My aim is to be able to connect myself from my local machine to a remote mongodb (version 3.2.8) instance with the following cmd:
mongo XX.XX.XXX.XXX:27017/myDB -u toto -p myPwd
i am getting this error
Error: 18 { ok: 0.0, errmsg: "auth failed", code: 18 } at src/mongo/shell/db.js:1210
exception: login failed
I checked the mongoDB documentation and i understood that i have to install the same version locally
So I updated my local mongodb with brew
like it is explained here Install MongoDB Community Edition on OS X and everything ran fine
toto$ brew install mongodb
toto$ Warning: mongodb-3.2.8 already installed
but when i try that:
toto$ mongod -version
db version v2.6.6
toto$ mongo -version
MongoDB shell version: 2.6.6
it seems that i am still using the old version locally.
I also tried to install it manually like it is explained in the documentation but nothing.
So I tried to set the path for mongo in my ~/.bashrc to use the version installed with brew like that:
toto$ cat ~/.bashrc
...
# Setting PATH for MongoDb 3.2.8
export MONGO_PATH=/usr/local/Cellar/mongodb/3.2.8
export PATH=$PATH:$MONGO_PATH/bin
...
but nothing.
What am I missing or misunderstanding ...?
I finally uninstall mongodb:
brew uninstall mongodb
I also did that just in case:
remove mongodb that was installed via brew
Raw
that helped me to found out the old mongoDB version (really used) so i removed everything from my local (binaries, the export in ~/.bashrc).
I restarted the machine, re install mongodb with brew and now everything is working properly.
Don't know why i didn't try that from the begining !
I hope it will help someone.
if it is the case don't forget to up vote please :)

The MongoDB PECL extension has not been installed or enabled [duplicate]

I am using Ubuntu 12.04 LTS and installed pecl in /opt/lampp/bin/ .
When installing second time its throwing error -
Command run previously -
pecl install mongo
pecl/mongo is already installed and is the same as the released
version 1.5.1 install failed
Now when I am Checking by -
echo extension_loaded("mongo") ? "loaded\n" : "not loaded\n";
It is showing not Loaded.
However I updated the php.ini with extension=mongo.so and restarted the server, but its not working.
Let me now what I am doing wrong.
EDIT
I re instantiated the command and following is the outcome -
Build process completed successfully
Installing '/opt/lampp/lib/php/extensions/no-debug-non-zts-20100525/mongo.so'
install ok: channel://pecl.php.net/mongo-1.5.1
configuration option "php_ini" is not set to php.ini location
You should add "extension=mongo.so" to php.ini
Finally with the help of Neil Lunn I made it the right way.
I added the full path and added the code at the very last line of my php.ini
extension="/opt/lampp/lib/php/extensions/no-debug-non-zts-20100525/mongo.so"
I got the solution for xampp in ubntu linux.
If this command not work for you pecl install mongo
you should type below command
sudo /opt/lampp/bin/pecl install mongo