Run mongod in ZSH shell on Mac and and get command not found - mongodb

I'm trying to run mongodin my terminal, but I'm getting a command not found. I've consulted other questions on this issue, including this these:
mac: command not found: mongod
Mongod: Command Not Found (OS X)
But the solutions have not worked for me.
Here is the full path of mongod:
/Users/danno/mongodb/bin/mongod
In .zshrc, I've tried two scripts, but neither one works:
Attempt 1 (from other Stack Overflow questions):
export PATH="$PATH:/usr/local/mongodb/bin"
Attempt 1 (My own guess):
export PATH="$PATH:/Users/danno/mongodb/bin/mongod"
I've restarted the terminal multiple times to no avail.
From the terminal, I'm trying to run:
mongod --dbpath=/Users/danno/mongodb-data
Getting a command not found while running that and also just with mongod alone.
Is something wrong with my pathing?

Maybe you forgot to do this step:
$ source ~/.bash_profile
It is better to put $PATH at the end.
I hope this will help. Additional options can be found in the post and the video.

Related

Running `mongod --config path` yields Error parsing command line

I was trying to create a mongodb (6.1.1) server with mongod with a custom config, but when I run mongod --config path the console yields Error parsing command line: Multiple occurrences of option "--config".
Running mongod alone or stuff like mongod --port 12345 seems to create the server, so I'm not sure why it's giving an error parsing the command line. Any path I give (absolute, relative, invalid) it yields the same error. The alias -f yields the same.
I doubt it matters but I installed mongo through scoop.
Alright found out the issue, it really is because of scoop.
Since one of scoop's objective is to prevent PATH polution, it writes an exe with the same name as the real executable, which runs behind the screen the real executable, with the help of the shim file.
Get-Command mongod yielded C:\Users\Plancha\scoop\shims\mongod.exe, and I thought that was the actual mongod. Turns out it isn't because it's in this shims folder. I understood this when I tried to copy and run this exe in the desktop (as kinda suggested by one of the commenters), and yielding Could not read shim file, leading me to make some further research about the package manager.
In conclusion, mongod.shim was:
path = "C:\Users\Plancha\scoop\apps\mongodb\current\bin\mongod.exe"
args = --config "C:\Users\Plancha\scoop\apps\mongodb\current\bin\mongod.cfg"
,
and the mongod.exe shim was simply passing the path, those args, and my additional args, leading to the multiple occurrences.
So to fix this, removing the args line was enough. I'll try and write a pull request to the main bucket.

second line on my system or python terminal now saying: “ -bash: zzzzz#: command not found“

I have been trying to pip install psycopg2 for some time now
I have just updated to python 3.7.4, before this problem started.
To set my path to a specific python version I used the code below.
nano .bash_profile
I thought that it would now be easy for my system to identify the path of the newly installed python, as to enable it to install psycopg2. Then the below started happening.
The second line of system terminal or python terminal is now always showing:
-bash: zzzzz#: command not found on my terminal
No matter what I type on my terminal, I am always getting command not found
This would mean you literally have "zzzzz" somewhere in the bash_profile. Bash is seeing "zzzzz" as just another command to run at startup like the rest of the profile script. As there is nothing in your PATH matching that string, bash reports the issue back to you.
Either remove the extra line from your .bash_profile. OR use a terribly wasteful work-around!
ln -s /bin/true /bin/zzzzz
This will create a symbolic link to the "true" binary (all it ever does is return true) from zzzzz. Now bash can find zzzzz and run it during start up, which does nothing. No more error and an absurd work around. You should fix the file.

Opening emacsclient in terminal works but won't work with Automator

So I'm getting some pretty strange behaviour when I try to use an Automator service to open new emacs (GNU Version 25.2 with spacemacs) buffers.
In my terminal, the command emacsclient -a '' -c works as expected, opening a new buffer through emacsclient. However, when I make a service in Automator which simply runs a (/bin/bash) shell script:
emacsclient -a '' -c
I get an error message:
The action “Run Shell Script” encountered an error: “emacsclient: could not get terminal name”
On suspicions that this was due to Automator not using some default PATH variable, I tried the following instead:
PATH=/usr/local/bin:$PATH
emacsclient -c
which produced the same error as before.
Next I tried
PATH=/usr/bin:/usr/local/bin export PATH;
emacsclient -c
which produced a different error message:
The action “Run Shell Script” encountered an error: “emacsclient: invalid option -- c
Try `emacsclient --help' for more information”
however why I try that script in my terminal it also gives a similar error which doesn't make much sense to me.
If anyone has suggestions for how to fix this I'd really appreciate it.
The problem is the shell script is running an old version of emacsclient in /usr/bin you need to run the one in Emacs.app/Contents/MacOS/bin/emacsclient. Delete the PATH line and you can use a solution listed here for running emacsclient inside automator Running a macOS service for open with emacs failed with "emacsclient: could not get terminal name mac"

Trouble setting up Sublime Text 3 to work with MongoDB [duplicate]

I'm using Mac Lion. I was using mongodb version 1.4. I wanted to upgrade to 1.8.5 and I followed http://shiftcommathree.com/articles/how-to-install-mongodb-on-os-x step wise replacing each mongodb-osx-x86_64-1.4.0 by mongodb-osx-x86_64-1.8.5. Everything goes smooth. I tried:
mongod
it's ok. I can access localhost:28017
but,
mongo
shows command not found
How can I fix this?
You need to add the path to "mongo" to your terminal shell.
export PATH=$PATH:/usr/local/mongodb/bin
Did you do the last step with paths.d? If so, try restarting your terminals.
Do you have a good reason for using 1.8.5? The current stable is 2.0.4, and it has many useful upgrades from 1.8.x
Starting from Mongodb version 6.0 mongo was replaced by mongosh
For readers in 2021:
export PATH="$PATH:/usr/local/opt/mongodb-community#3.6/bin"
You'll have to add the location of the Mongo binary to PATH.
Follow the steps below in order to make the PATH variable permanent:
Open Terminal and navigate to your user directory.
Run touch ~/.bash_profile and then open ~/.bash_profile.
In TextEdit, add export PATH="<mongo-directory>/bin:$PATH" (Keep the quote marks - related to white spaces).
Save the .bash_profile file and Quit (Command + Q) Text Edit.
Run source ~/.bash_profile.
Run echo $PATH and check if the you see that the Mongo binary was added.
(*) Notice that the PATH variable is now available only for the current terminal and not to processes that were already started in the session.
In order to make it available outside the current terminal - you'll have to logout and login.
1.Go to your [mongodb installation dir]:
cd <mongodb installation dir>
2.Type ./bin/mongo to start mongo:
./bin/mongo
Read More
Note :
If above command gives error
Failed global initialization: BadValue Invalid or no user locale set. Please ensure LANG and/or LC_ environment variables are set correctly.*
Run bellow command: Read More
export LC_ALL=C
How can find installation directory
find / -name "mongodb"
You can also set path
export PATH=$PATH:<mongodb installation dir>/bin
documentation
export PATH={mongodb-install-directory}/bin:$PATH
In Mac:
Go into Bash Profile:
vi ~/.bash_profile
Add Path of Installation of MongoDB:
export PATH=$PATH:/usr/local/opt/mongodb-community#4.2/bin
Reload the Bash Profile:
source ~/.bash_profile
You can navigate to the mongo directory using the command line and then start MongoDB with
./mongodb
I was facing the same problem this worked for me.
you need to install mongodb shell to ge the mongo command working.
Download link
I didn't have the right mongo command line tools installed. This from Brew worked for me though.
brew install mongodb-community
just a little recommandation, if your path has a space just wrap the whole path with quote or doublequote
example : C:\Program Files\MongoDB\Server\4.2 . notice the space in "Program Files"
export PATH=$PATH:"C:/Program Files/MongoDB/Server/X.X/bin"
in place of mongo command use mongosh command and it will work.

Can we run mongoDB shell at any location/directory in unix [duplicate]

I'm using Mac Lion. I was using mongodb version 1.4. I wanted to upgrade to 1.8.5 and I followed http://shiftcommathree.com/articles/how-to-install-mongodb-on-os-x step wise replacing each mongodb-osx-x86_64-1.4.0 by mongodb-osx-x86_64-1.8.5. Everything goes smooth. I tried:
mongod
it's ok. I can access localhost:28017
but,
mongo
shows command not found
How can I fix this?
You need to add the path to "mongo" to your terminal shell.
export PATH=$PATH:/usr/local/mongodb/bin
Did you do the last step with paths.d? If so, try restarting your terminals.
Do you have a good reason for using 1.8.5? The current stable is 2.0.4, and it has many useful upgrades from 1.8.x
Starting from Mongodb version 6.0 mongo was replaced by mongosh
For readers in 2021:
export PATH="$PATH:/usr/local/opt/mongodb-community#3.6/bin"
You'll have to add the location of the Mongo binary to PATH.
Follow the steps below in order to make the PATH variable permanent:
Open Terminal and navigate to your user directory.
Run touch ~/.bash_profile and then open ~/.bash_profile.
In TextEdit, add export PATH="<mongo-directory>/bin:$PATH" (Keep the quote marks - related to white spaces).
Save the .bash_profile file and Quit (Command + Q) Text Edit.
Run source ~/.bash_profile.
Run echo $PATH and check if the you see that the Mongo binary was added.
(*) Notice that the PATH variable is now available only for the current terminal and not to processes that were already started in the session.
In order to make it available outside the current terminal - you'll have to logout and login.
1.Go to your [mongodb installation dir]:
cd <mongodb installation dir>
2.Type ./bin/mongo to start mongo:
./bin/mongo
Read More
Note :
If above command gives error
Failed global initialization: BadValue Invalid or no user locale set. Please ensure LANG and/or LC_ environment variables are set correctly.*
Run bellow command: Read More
export LC_ALL=C
How can find installation directory
find / -name "mongodb"
You can also set path
export PATH=$PATH:<mongodb installation dir>/bin
documentation
export PATH={mongodb-install-directory}/bin:$PATH
In Mac:
Go into Bash Profile:
vi ~/.bash_profile
Add Path of Installation of MongoDB:
export PATH=$PATH:/usr/local/opt/mongodb-community#4.2/bin
Reload the Bash Profile:
source ~/.bash_profile
You can navigate to the mongo directory using the command line and then start MongoDB with
./mongodb
I was facing the same problem this worked for me.
you need to install mongodb shell to ge the mongo command working.
Download link
I didn't have the right mongo command line tools installed. This from Brew worked for me though.
brew install mongodb-community
just a little recommandation, if your path has a space just wrap the whole path with quote or doublequote
example : C:\Program Files\MongoDB\Server\4.2 . notice the space in "Program Files"
export PATH=$PATH:"C:/Program Files/MongoDB/Server/X.X/bin"
in place of mongo command use mongosh command and it will work.