Skip to main content

Mongo DB

Mongodb DAAS https://mlab.com/

GUI for mongo https://www.mongodb.com/products/compass

mongod process url

Install mongodb on OSX

https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/

brew tap mongodb/brew
brew install mongodb-community

You can run MongoDB as a macOS service using brew, or you can run MongoDB manually as a background process. It is recommended to run MongoDB as a macOS service, as doing so sets the correct system ulimit values automatically (see ulimit settings for more information).

  • To run MongoDB (i.e. the mongod process) as a macOS service, issue the following:

copycopied

brew services start mongodb-community@4.4

To stop a mongod running as a macOS service, use the following command as needed:

copycopied

brew services stop mongodb-community@4.4
  • To run MongoDb (i.e the mongod process) manually as a background process issue the following:

copycopied

mongod --config /usr/local/etc/mongod.conf --fork

To stop a mongod running as a background process, connect to the mongod from the mongo shell, and issue the shutdown command as needed.

Both methods use the /usr/local/etc/mongod.conf file created during the install. You can add your own MongoDB configuration options to this file as well.

MACOS PREVENTS MONGOD FROM OPENING

macOS may prevent mongod from running after installation. If you receive a security error when starting mongod indicating that the developer could not be identified or verified, do the following to grant mongod access to run:

  • Open /System Preferences/
  • Select the /Security and Privacy/ pane.
  • Under the /General/ tab, click the button to the right of the message about mongod, labelled either Open Anyway or Allow Anyway depending on your version of macOS.

To verify that MongoDB is running, search for mongod in your running processes:

copycopied

ps aux | grep -v grep | grep mongod

Create a database

mongo to enter shell

show dbs shows databases

use new_db_name

#development/mongodb