zsh: command not found: mongo - mongodb

I'm following the official instructions found here (on Mac OS Big Sur): https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/
When attempting to run mongo, I receive:
zsh: command not found: mongo
I then check if MongoDB is running by running:
brew services start mongodb-community#4.4
I then receive:
Service mongodb-community#4.4 already started, use brew services restart mongodb-community#4.4 to restart
Because of this, I know MongoDB is running. What gives? I followed the official instructions from MongoDB's website.

For Apple M1 Processor:
If you install mongodb through Homebrew, follow the steps below:
Open up your Terminal
Type brew list to check the formulae of the installed mongodb
==> Formulae
mongodb-community#4.4 mongodb-dxxx...
==> Casks
xxxxx
In my case, it is mongodb-community#4.4.
In the terminal, type brew list mongodb-community#4.4 to get the directory of the mongodb installed in your machine.
/opt/homebrew/Cellar/mongodb-community#4.4/4.4.13/bin/install_compass
/opt/homebrew/Cellar/mongodb-community#4.4/4.4.13/bin/mongo
/opt/homebrew/Cellar/mongodb-community#4.4/4.4.13/bin/mongod
/opt/homebrew/Cellar/mongodb-community#4.4/4.4.13/bin/mongos
/opt/homebrew/Cellar/mongodb-community#4.4/4.4.13/homebrew.mxcl.mongodb-community#4.4.plist
/opt/homebrew/Cellar/mongodb-community#4.4/4.4.13/MPL-2
/opt/homebrew/Cellar/mongodb-community#4.4/4.4.13/THIRD-PARTY-NOTICES
Copy the bin path of your mongodb: /opt/homebrew/Cellar/mongodb-community#4.4/4.4.13/bin
Open up your .zshrc file with any text-editor
Add this line to the file:
export PATH="/opt/homebrew/Cellar/mongodb-community#4.4/4.4.13/bin:${PATH}"
Try mongo --version in your terminal, if you see similar output like shown below, you are good to go.
MongoDB shell version v4.4.13
Build Info: {
"version": "4.4.13",
"gitVersion": "df25-----------b9246",
"modules": [],
"allocator": "system",
"environment": {
"distarch": "x86_64",
"target_arch": "x86_64"
}
}

I did the above procedures and it still didn't work. But use this, then it worked!
brew install mongodb-community-shell

I solved my problem with this command running on terminal but only path I added is diffrent
Steps:
brew list mongodb-community#4.0. (run this first)
then copied /opt/homebrew/Cellar/mongodb-community#4.0/4.0.28/bin. this path
and executed:
echo 'export PATH="/opt/homebrew/Cellar/mongodb-community#4.0/4.0.28/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
Then I have checked by openning .zshrc file is my path has set on not by executing - nano .zshrc command

echo 'export PATH="/usr/local/opt/mongodb-community#4.4/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

I did the above procedures and it still didn't work. But I restarted my terminal using $exec bash -l and it works!

Related

MongoDB , zsh: command not found: mongo

I just installed MongoDB through homebrew and ran it as a macOS service, then I started the server with command:
brew services start mongodb-community#4.4
==> Successfully started mongodb-community#4.4 (label: homebrew.mxcl.mongodb-community#4.4)
so it's running
but when I tried to run the mongo shell with command: mongo
it just showed zsh: command not found: mongo
add the mongo location path to the zsh PATH variable:
echo export PATH=/opt/homebrew/opt/mongodb-community#4.4/bin:$PATH >> ~/.zshrc
open new terminal and try starting again

mongodb installation on mac using brew with zsh

I'm using zsh and installed mongo using: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/
when trying to use mongod --config /usr/local/etc/mongod.conf --fork I get:
➜ ~ brew list
gettext openjdk scala#2.11
git pcre2
mongodb-community#4.0 sbt
➜ ~ brew services start mongodb-community#4.0
Service `mongodb-community#4.0` already started, use `brew services restart mongodb-community#4.0` to restart.
➜ ~ mongod --config /usr/local/etc/mongod.conf --fork
zsh: command not found: mongod
Can someone help?
It looks like you haven't set path variable for mongodb. You can set it in .zshrc file.
Open .zshrc file in vim using vim ~/.zshrc
then paste the following line
export PATH="<your mongodb bin folder path>:$PATH"
in my case the path is
/Users/namardeepsood/Development/mongodb/bin
save this file and run source ~/.zshrc to refresh the current shell environment.

brew services start postgresql not working

I have installed postgres in Mac using command
brew install postgresql#9.6
and is successfully installed
brew services start postgresql#9.6 is successful also
==> Successfully started postgresql#9.6 (label: homebrew.mxcl.postgresql#9.6)
But when I tried to access Postgres from my Mac terminal psql postgresql#9.6 it prompt me weird error
-bash: /usr/local/bin/psql: No such file or directory
Am I doing something wrong, how to open psql from my terminal
Why there is no psql file in my /usr/local/bin
The accepted answer is incorrect.
If you install postgresql#9.6 via Homebrew, the right path for the /bin folder is:
/usr/local/Cellar/postgresql#9.6/9.6.15/bin
To connect, just type: psql postgres
If you're curious about the connections details, just type \conninfo and check it.
You must to enabling Postgres command line tools.
If you are using the default terminal, you are going to want to modify the file at
~/.bash_profile
. If you are using something like Oh My Zsh you are going to want to modify the file ~/.zshrc.
To edit this file you likely need to open it via the terminal, so open your terminal and type open ~/.bash_profile. You can replace the word open with subl or whatever text editor you prefer.
Once your zbash_profile or .zshrc file is open, add the following line to the end of the file:
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin
After that you will need to quit and restart your terminal This is to make sure it reloads with the changes you just made.
Once you have restarted your terminal, try running psql.
psql -U postgres
You should get the following output.
psql (9.6.0)
Type "help" for help.
postgres=#
You can read more on https://www.calhoun.io/how-to-install-postgresql-9-6-on-mac-os-x/

How to brew uninstall postgres on OX Sierra

Reading from the here, I want to uninstall postgres completely with homebrew and have used brew uninstall postgresql but I get this response.
No such keg: /usr/local/Cellar/postgresql
I know postgres is running because when I run ps auxwww | grep postgres I see /usr/local/opt/postgresql94/bin/postgres -D /usr/local/var/postgres. What am I doing wrong? I have mac Sierra
I installed postgres using homebrew. I uninstalled it using the following steps:
Run the following command and look for the correct name something like postgresql94, postgres, postgresql#13. Name may varies, you have to check accordingly. In my case it was postgresql94.
brew list
After finding the correct name, run the following command to uninstall postgres. You have to replace postgresql94 with the name you found in the above mentioned command:
brew uninstall postgresql94
That should do the uninstall.
Shortcut command for the same is
brew list | grep postgres | xargs brew uninstall

mongoDB error: Error: failed to connect to [localhost:27017]

I'm trying to install habitrpg locally but I keep getting a mongoDB error after typing node src/seed.js:
Error: failed to connect to [localhost:27017]
I saw on other questions with the same error people have suggested typing in 'mongod' and that fixes it by creating a local server. I get the error:
-bash: mongod: command not found
Can't figure out what's wrong. Any ideas?
Open CMD (In Windows) or terminal (In Ubuntu).
type command >cd PATH_FOR_MONGODB_BIN_FOLDER
cd C:\Program Files\MongoDB\Server\3.2\bin
for ubuntu command will be same :
cd /home/MongoDB/Server/3.2/bin
then type command >mongod --dbpath PATH_FOR_DATA_FOLDER
mongod --dbpath C:\data\db
For ubuntu command will be :
./mongod --dbpath /home/data/db
you can specify any folder as data folder.
Wait till CMD or Terminal shows "waiting for connections"
2016-09-01T21:38:33.170+0530 I NETWORK [initandlisten] waiting for connections on port 27017
Then open new CMD or terminal window.
type command >cd PATH_FOR_MONGODB_BIN_FOLDER ( same as step 3 )
cd C:\Program Files\MongoDB\Server\3.2\bin
Don't close previous window of cmd or teminal.
then run mongodb by typing "mongo" in windows or "./mongo" in ubuntu
mongo
For ubuntu
./mongo
After mongodb run successfully you can close previous CMD window.
You don't have MongoDB installed. Follow the directions for your system to install it: http://docs.mongodb.org/manual/installation/
From the habitRPG docs:
Before starting make sure to have MongoDB, NodeJS and npm and Git installed and set up.
I think that you don't have an environmental variable declared. Assuming that your MongoDB installation is C:\ProgramFiles\MongoDB\Server\YOUR_VERSION_NUMBER\, you should just add the bin folder path of that version of MongoDB to your PATH system environment variable.
Here's a link where you can find the way to do that without complications :
http://www.computerhope.com/issues/ch000549.htm
After installing MongoDb you have to add the directory "data\db" under the C:\ directory,
then you should start the mongod.exe
on windows open task manager || Ctrl + shift + ESC > select service tab > search for mongo db > right click > start service
I got this issue because I didn't have MongoDB. So I installed MongoDB and tried to run node application and it worked.
If you don't have MongoDB then follow below steps to install and enjoy
Commands :
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
$ echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
$ sudo apt-get update
$ sudo apt-get install -y mongodb-org
Then type mongo in terminal and if you will get console for mongo then it's done.
Type sudo pip3 install mongodb, then sudo pip3 install pymongo, then mongod.
I had the same problem on my Mac.
I updated my Homebrew files, after I reinstaled MongoDB in my terminal
brew tap mongodb/brew
and
brew install mongodb-community#5.
and I started mongo server
brew services start mongodb/brew/mongodb-community
After that I coud to commect.
my problem is the connectoon is down, run script:
brew services start mongodb-community
And up mongoDB Compass and works.
I ran mongodb install file and choose repair