Install MongoDB without homebrew on Mac OS πŸ‘¨πŸ»β€πŸ’»

Saurabh Kumar
KhojChakra
Published in
4 min readJan 5, 2019

well as a Mac user, I personally prefer homebrew to install a new package in my MacBook. but sometimes due to upgrade in os or due to some technical issue or maybe some other shit..!! the brew is unable to install the desired package.

screenshot of brew failed to install MongoDB

and you don’t have time to debug the issue because time is money 😜

don’t worry.. I will tell you how to install MongoDB step by step without homebrew

first download MongoDB from its official website https://www.mongodb.com/download-center/community hit server tab, by default it will land you on cloud tab

download MongoDB community server

after that go to your download folder through terminal screenshot and command both given below

cd Downloads/

you will see the downloaded tar file of MongoDB. use the below command πŸ‘‡ to extract tar file to the corresponding folder

tar xzf mongodb-osx-ssl-x86_64-4.0.5.tgz

now move the extracted folder to /usr/local/mongodb by using the command

sudo mv mongodb-osx-x86_64-4.0.5 /usr/local/mongodb

by default MongoDB stores the data in the folder/data/db, which is not present by default, so we have to create it manually by the command

sudo mkdir -p /data/db

after that, we need to manually change the permission of /data/db folder by command but first check your username, you can find it by command whoami and use it in the below command as I do

sudo chown saurabh /data/db

now we have to add all the path of MongoDB to the bash profile, for that first go to the home directory by cd command and verify it by pwd like below

now list all hidden files by ls -al you will find .bash_profile over there, if not, create it with command touch .bash_profile

open .bash_profile with command open .bash_profile

you will see it will open in textEdit and it will be something like that based on your current system configuration πŸ‘‡

now copy the below code πŸ‘‡ to the end of your .bash_proflie

export MONGO_PATH=/usr/local/mongodb export PATH=$PATH:$MONGO_PATH/bin

and save it by pressing β€œcommand + s”. your .bash_profile will now look something like below

after saving close the .bash_profile and hit the command source .bash_profile to reload it and that's it…!!! πŸ˜ƒ

you have done all the steps required to install MongoDB in your system.

now it’s time to check if it has been installed successfully or not. for that open two terminals like below πŸ‘‡ and in one of the terminal first type the command mongod and execute it to start mongo demon and in another type mongo and press enter to interact with MongoDB.

Congratulations..!! πŸŽ‰ πŸŽ‰ πŸ˜ƒ you have successfully installed MongoDB without homebrew. Go get yourself a beer for all the hard work you have done. cheers..!! 🍺

P.S. If you like this article and want more like these, please press clap as much as you like

About the Author

feel free to follow me on GitHub πŸ‘‰ https://github.com/SK-CSE

or connect with me on LinkedIn πŸ‘‰ https://www.linkedin.com/in/saurabh-kumar-7748015a/

for more post like this follow us πŸ‘‰ https://medium.com/khojchakra

--

--

Saurabh Kumar
KhojChakra
Editor for

a guy who believe in spreading love, peace and knowledge.. a Senior Software Engineer working remotely