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
Related
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 have installed MongoDB in the C drive. the bin folder is in the below path.
i have also created the data and log folders.within the data folder have created a folder named db
C:\Program Files\MongoDB\Server\3.4\bin
i have opened the cmd and navigated to the bin folder and type the below command
mongod --directoryperdb --dbpath C:\Program Files\MongoDB\Server\3.4\data\db --logpath C:\Program Files\MongoDB\Server\3.4\log\mongo.log --logappend --rest --install
i am getting the below error
and when i type the below command also i am getting an error
guys i am clueless ,pls help me out
can you try this:
mongod --directoryperdb --dbpath "C:\Program Files\MongoDB\Server\3.4\data\db" --logpath "C:\Program Files\MongoDB\Server\3.4\log\mongo.log" --logappend --rest --install
The error can be because of the space between "Program Files".
For the second error, it is because MongoDB is not installed as a service.
You can check you this answer to see how to setup mongo as a service.
I have a file named db.sh in bin folder and when I try to execute this command $ sh bin/db.sh I receive bin/db.sh: line 2: mongod: command not found in console what is wrong there?
#!/bin/sh
mongod --dbpath db --rest --jsonp;
Here is the situation:
which mongod would give you the path to the mongod binary. If there is no output from which, there which could not find mongod. This may be the case that there is not path in the $PATH variable, that contains the mongod binary. You can make sure by executing echo $PATH.
If you have your MongoDB installed manually, in some directory, then you will need to add /path/to/your/mongodb/bin to the $PATH variable in your .bashrc, like this:
PATH=/path/to/your/mongodb/bin:$PATH
But anyway :) seems like you do not have MongoDB installed on your machine. Follow this article to install it.
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 :)
I was following this quickstart guide, http://www.mongodb.org/display/DOCS/Quickstart+OS+X, but I got lost when they told me to to execute ./mongodb-xxxxxxx/bin/mongod, in which directory do I execute this command? I tried to find / -name mongodb results matched that directory format.
To start Mongo, run that command in the root installation directory of mongo, so, assuming you installed mongo in /opt/mongo/mongodb-linux-x86_64-2.0.2, just run in that folder like this...
/opt/mongo/mongodb-linux-x86_64-2.0.2$ ./bin/mongod
Add any additional parameters you need to start the instance, this is how I run my instance....
./bin/mongod --fork --dbpath /opt/mongo/data/db1/dbs --port 33479 --logpath /opt/mongo/data/db1/log/db1.log -logappend
My personal favorite way to install just about anything, including MongoDB, on Mac OS X:
/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"
brew install mongodb