How do i run mongo shell outside my installation directory? - mongodb

Whenever I run mongo on command line i get
'mongo' is not recognized as an internal or external command,
operable program or batch file.
I'll have to change to my directory first to run mongo shell, which is pretty deep in my directory.
How do can I run mongo shell without changing my directory?

Related

After setting variable showing this error again 'mongo is not recognized as an internal or external command, operable program or batch file

I have installed mongodb and put a path in environment variable.When i use cmd it still throwing error which is 'mongo' is not recognized as an internal or external command,
operable program or batch file.
enter image description here
enter image description here
The mongo executable is deprecated and no longer available in 6.0.
Keep in mind this is just the shell, mongod is the binary that runs the database.
mongosh is the new shell.
Look in C:\Program Files\MongoDB\Server\6.0\bin to see the binaries that exist.

Mongodb command not recognized

I am learning a mongodb tutorial and I'm new to it and I tried executing mongodb commands but the cmd is showing
C:\Users\paanc_ctx7xp6>mongod --version
'mongod' is not recognized as an internal or external command,
operable program or batch file.
although I added path variable it still isn't working. I even tried adding "" after bin but anything I have done isn't working at all , and I can't seem to get an answer because everyone is simply saying to edit path variable. Can someone please help me
path variable
cmd

'mongod' is not recognized as an internal or external command, operable program or batch file

I installed mongoose with npm i mongoose it shows in the package.jason dependencies also but when I run the command mongod it shows the error 'mongod' is not recognized as an internal or external command, operable program or batch file
how to fix this error

How do I know which MongoDB version is installed by using the Command Line?

Without changing directory to \MongoDB\bin\, when I call:
mongod -v
I get:
'mongod' is not recognized as an internal or external command, operable
program or batch file.
When I call the same command from \bin\ it launches the server just like I'm calling:
mongod
It is the same case with 'mongo' and 'mongos'.
I added the \bin\ path to the environment variables thinking it will help but it didn't.
To clarify with an example, to get the version of Ruby, I can call:
ruby -v
Why can't I do the same with MongoDB?
First add location of MongoDB's bin folder to PATH env variable. This is required because it is the place where mongod.exe is stored.
For example, if MongoDB 4.0 is in your Program Files, add "C:\Program Files\MongoDB\Server\4.0\bin" to PATH for all system users.
Then try using :
mongod --version

Getting error while starting mongo shell

I created a bin folder in user account and paste mongo inside this folder. I successfully created conf and log file also and my server also running.
I checked that by using grep command.
But if i try to use mongo shell it says"Command not found"
If this is Linux or another Unix-like OS and you are in the directory where you put the mongo executable, you need to type "./mongo" to run the shell. This is not MongoDB specific, it's just the way Unix-like systems work. If you are in a different directory, specify the path to the mongo executable (e.g. "~/bin/mongo") or add "~/bin" to your PATH environment variable.