How to start a mongodb service on mac OS X?
If you used homebrew to install MongoDB on macOS you type the following in terminal. Should do the trick in most cases.
$ brew services start mongodb
Try the following steps in Terminal:
which mongod
This will output the path to your mongod
, but if it is not in your $PATH
the command output will be empty. So you need to find your executable:
find / -name 'mongod'
In the output of this command, you will see many lines, one of which will be like bin/mongod
, e.g. /usr/local/mongodb/bin/mongod
. In that case take the whole absolute path and do the following:
echo "PATH=/usr/local/mongodb/bin/:$PATH" >> ~/.bash_profile
. ~/.bash_profile
Then try again:
mongod --dbpath /your/path
Just do brew services start mongodb-community
. Example:
$ brew services list
Name Status User Plist
mongodb-community stopped
$ brew services start mongodb-community
==> Successfully started `mongodb-community` (label: homebrew.mxcl.mongodb-community)
Of course, depends on your installation. This is the typical brew install.
As now is 2021 year, so start mongodb
on Mac:
Use brew
-
brew services start mongodb-community
- for installed by:
brew install mongodb-community
- for installed by:
similarly:
for specify version
-
brew services start [email protected]
- for installed by:
brew services install [email protected]
- for installed by:
only running not want bootable
the start
means start and enable start at launch/boot
for only run currently, use run
:
brew services run mongodb-community
check status
after start, check status use:
brew services
Manually
for old version mongodb
, the command is mongod
:
- Directly run:
mongodb
- Run with config:
mongod --config /usr/local/etc/mongod.conf
- the default config file path is:
/usr/local/etc/mongod.conf
- the default config file path is:
- Run with only pass some parameter:
- with database path:
mongod --dbpath /data
-
/data
is common mongodb database path
-
- with database path: