Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start a mongodb service on mac OS X?

Tags:

macos

mongodb

I have already installed Mongodb on my mac but the process is currently not running. How do I start the Mongodb service so that I can start using the commands?

like image 805
nshetty Avatar asked Jul 22 '15 13:07

nshetty


People also ask

How do I start MongoDB from terminal?

To start MongoDB, run mongod.exe from the Command Prompt navigate to your MongoDB Bin folder and run mongod command, it will start MongoDB main process and The waiting for connections message in the console.

How do I start MongoDB server shell?

To open up the MongoDB shell, run the mongo command from your server prompt. By default, the mongo command opens a shell connected to a locally-installed MongoDB instance running on port 27017 . Try running the mongo command with no additional parameters: mongo.


2 Answers

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 
like image 54
kinxiel Avatar answered Oct 03 '22 01:10

kinxiel


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 
like image 34
bagrat Avatar answered Oct 03 '22 02:10

bagrat