Show Menu
Cheatography

MongoDB Community for MacOS Intel Cheat Sheet by

I created this cheatsheet to stop searching the Internet when having to come back to MongoDB since I do not work with it everyday.

Instal­lation

Install XCode
xcode-­select --install
Homebrew tap
brew tap mongod­b/brew
Homebrew update
brew update
Homebrew install latest
brew install mongod­b-c­omm­unity
Homebrew install specific version
config­uration file
/usr/l­oca­l/e­tc/­mon­god.conf
log directory
/usr/l­oca­l/v­ar/­log­/mo­ngodb
create data directory
/usr/l­oca­l/v­ar/­mongodb

/usr/l­oca­l/e­tc/­mon­god.conf

proces­sMa­nag­ement:
 
 ­fork: true
net:
 
 ­bindIp: localhost
 
 ­port: 27017
storage:
 
 ­dbPath: /usr/l­oca­l/v­ar/­mongodb
systemLog:
 
 ­des­tin­ation: file
 
 ­path: "­/us­r/l­oca­l/v­ar/­log­/mo­ngo­db/­mon­god.lo­g"
 
 ­log­Append: true
storage:
 
 ­jou­rnal:
 
 ­ ­ ­ena­bled: true

clients

Terminal
mongosh
Studio 3T
MongoDB Compass
Robo 3T
NoSQLB­ooster
Humong­ouS.io
NoSQL Manager
DronaHQ
MongoDB Database Tools
 

Is MongoDB Running?

check if running on port
lsof -i tcp:27017
check if process running
ps -ax | grep mongo

MongoDB Community Edition as service

start mongo db service
brew services start mongod­b-c­omm­unity
start specific mongo db version
brew services start mongod­b-c­omm­uni­ty@6.0
stop mongo db service
brew services stop mongod­b-c­omm­unity

MongoDB Community Manual

start manually
mongod --config /usr/l­oca­l/e­tc/­mon­god.conf --fork
stop mongdb step 1
mongsh
stop mongodb step 2
use admin
stop mongodb step 3
db.shu­tdown()

Troubl­esh­ooting

Client Connection Refused Error
MongoDB is not running
MongoDB cannot run on port
sudo rm /tmp/m­ong­odb­-27­017.sock
Check logs
cat /usr/l­oca­l/v­ar/­log­/mo­ngo­db/­mon­god.log
MongoDB Cannot run missing data directory
mkdir /usr/l­oca­l/v­ar/­mongodb
MacOS Prevents mongosh Running
System Prefereces > Security & Privacy > General > Open Anyway or Allow Anyway
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          More Cheat Sheets by slohja