Step-by-step tutorial: How to install MongoDB without homebrew
- download MongoDB community server from its official website: https://www.mongodb.com/download-center/community
- Extract downloded file
cd Downloads/
tar xzf mongodb-macos-x86.64-x.x.x.tgz
Move the extracted folder to /usr/local/mongodb
by using the command
sudo mv mongodb-macos-x86.64-x.x.x /usr/local/mongodb
- MongoDB stores the data in the folder
/data/db
We will create it manually by the command
sudo mkdir -p /data/db
- Change the permission of
/data/db
folder
-> to check your username, use commandwhoami
sudo chown yourUsername /data/db
- Add all the path of MongoDB to the bash profile,
-> go to the home directory bycd
command and verify it bypwd
-> list all hidden files byls -al
you will find.bash_profile
, if not, create it with commandtouch .bash_profile
-> Open.bash_profile
with commandopen .bash_profile
-> Add below code to the end of your.bash_proflie
....
export MONGO_PATH=/usr/local/mongodb
export PATH=$PATH:$MONGO_PATH/bin
-> Save and quit
->Hit the command source .bash_profile
to reload it.
- MongoDB is installed in your system.
- Check if it has been installed successfully or not:
-> Open two terminals and
-> In one of the terminal execute the commandmongod
to start mongo demon
-> In another typemongo
and press enter to interact with MongoDB.
You have successfully installed MongoDB without homebrew.
Congratulations..!!