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
Related
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!
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.
I installed mongodb by brew on my MacOS as the mongodb official documentation, but I tried to run MongoDB manually as a background process, use command "mongod --config /usr/local/etc/mongod.conf --fork". Then the terminal displayed the message is : command not found: mongo.
Did I miss any steps?
The above error appears when mongodb executable is not included in the PATH environment variable.
MongoDB gets installed to /usr/local/bin/mongod
The command 'mongod --config /usr/local....' will work only if '/usr/local/bin' is included in PATH.
How to fix the problem?
The problem can be fixed in 2 ways -
Calling the mongod command with full path
/usr/local/bin/mongod --config /usr/local/etc/mongod.conf --fork
Adding '/usr/local/bin' to PATH
export PATH=$PATH:/usr/local/bin
Run the above command or add the above line to the end of .zshrc file and .bash_profile file and execute mongodb command in a new terminal window.
mongod --config /usr/local/etc/mongod.conf --fork
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
I'm trying to experiment with mongoDB's new full text search:
http://docs.mongodb.org/manual/tutorial/enable-text-search/
However, when I either use the parameter in the mongod command, or in a config file, I get the following error:
[root#bobby etc]# /usr/bin/mongod --dbpath /home/bobby/data/ --setParameter textSearchEnabled=true
error command line: unknown option setParameter use --help for help
And I'm running the latest version of MongoDB on Scientific Linux
[root#bobby etc]# mongo
MongoDB shell version: 2.4.3
connecting to: test
Interestingly, setParameter isn't listed in --help either:
[root#bobby etc]# /usr/bin/mongod --help | grep setParameter
(nothing)
It was because yum was only updating mongo, not mongo-server.
So I used the command:
yum install mongo-10gen-server.x86_64
And now everything works :)