

By default in Mac it’s /usr/local/var/mongodb. To start using mongodb open a new terminal window, locate where your mongodb is installed and go there. After this run mongodb by typing this to terminal. Then go to your finder and make sure user account running mongodb has read and write permissions for the directory.


This will make a default directory for mongo to use. Go to your system root and type following command to terminal. Then you need to create a directory where mongoDB can write data. Start by opening a terminal and run following commands on system shell.

You need to have homebrew installed on your mac to run these commands. Here’s instructions how to install it locally on your Mac. We have to specify the authentication database to allow database users to log in via shell.MongoDB is a NoSQL database, used mostly together with Node.js. # Save and exit the editor by pressing Ctrl + O -> Enter, Ctrl + XĪlso, update the alias by updating the ~/.zshrc as shown below.Īlias mongod="/usr/local/mongodb/bin/mongod -config /usr/local/mongodb/nf"Īfter enabling the authorization, we can connect to MongoDB via MongoDB Shell by executing it with options as shown below. Next, we will create the configuration file and update mongod alias to use the configuration file. This is how we can add admin users to the admin database and assign a role to the user. Now we will add the user admin with root role to the admin database using the commands as shown below.ĭb.createUser( ) We can see that MongoDB has already created three databases i.e. Start MongoDB server and MongoDB Shell using the aliases created by us in the previous steps. In this step, we will add the default admin user with root privileges and also enable Access Control to allow authenticated users. Save and exit the editor using the commands Ctrl + o -> Enter and Ctrl + x. Sudo mv mongosh-1.1.1-darwin-圆4 /usr/local/mongoshĪlso, add an alias by updating the ~/.zshrc as shown below.Īlias mongod="/usr/local/mongodb/bin/mongod -dbpath /System/Volumes/Data/data/db"Īlias mongo="/usr/local/mongodb/bin/mongo"Īlias mongosh="/usr/local/mongosh/bin/mongosh" Now install mongosh by following the same steps as we did for MongoDB using the commands shown below.
