How to start a mongodb service on mac OS X?

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?

Answers


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

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

To start the mongodb, you should only have to run the "mongod" command on the terminal.


Just go into a folder where you want mongodb to store all the database files and run the command

mongod --dbpath=.


Use this line it will fix the issue.

Execute this line in your terminal at the mongo bin path:

export PATH=<mongodb-install-directory>/bin:$PATH

<mongodb-install-directory> replace this with your path, for example:

export PATH=/Application/Mongo/bin:$PATH

Install and Run MongoDB with Homebrew

Open the Terminal app and type

brew update

After updating Homebrew

brew install mongodb

After downloading Mongo, create the “db” directory. This is where the Mongo data files will live. You can create the directory in the default location by running

sudo mkdir -p /data/db

Make sure that the /data/db directory has the right permissions by running

sudo chown -R id -un /data/db

Run the Mongo daemon, in one of your terminal windows run

mongod

This should start the Mongo server. Run the Mongo shell, with the Mongo daemon running in one terminal, type mongo in another terminal window. This will run the Mongo shell which is an application to access data in MongoDB. To exit the Mongo shell run quit() To stop the Mongo daemon hit ctrl-c

start service:

brew services start mongo

https://treehouse.github.io/installation-guides/mac/mongo-mac.html


Need Your Help

Replace string in a text file in node.js

javascript node.js

I am using node.js. I want to read a file with some placeholder strings and replace them dynamically before I serve the file. This is not an HTML file, so a templating engine will not work.

jquery.ui.spinner change

jquery events user-interface spinner onchange

I'm trying to use the latest version of the jquery.ui.spinner.js . http://wiki.jqueryui.com/w/page/12138077/Spinner