Skip to content

Instantly share code, notes, and snippets.

@isramv
Last active October 23, 2021 13:33
Show Gist options
  • Save isramv/aca2ea47313fa316b335 to your computer and use it in GitHub Desktop.
Save isramv/aca2ea47313fa316b335 to your computer and use it in GitHub Desktop.
How to install mongodb on Mac Yosemite 10.10.4

how to install Mongo db on Mac Yosemite 10.10.4

I will be following the official documentation here but they take some things for granted, many users could get frustrated and confused that's why I created this gist.

I have downloaded the mongo files in my root user directory for example: /Users/israel/mongodb therefore if you want to do the same first enter cd in your terminal.

then enter pwd command in your terminal and you should be able to se something similar to /Users/<yourmacuser>

If the previous is correct you may want to proceed and open the terminal then download the tar:

curl -O https://fastdl.mongodb.org/osx/mongodb-osx-x86_64-3.0.5.tgz

Extract the tar

tar -zxvf mongodb-osx-x86_64-3.0.5.tgz

Then:

mkdir -p mongodb
cp -R -n mongodb-osx-x86_64-3.0.5/ mongodb

In Mac OS you have to create the file .bash_profile here is where we are going to point the binaries so you can access the mongod command everywhere.

nano .bash_profile

Add the following line to the file:

export PATH="/Users/<yourmacusername>/mongodb/bin:$PATH"

Save the file. Mongo should be accesible now

Data folder

I created the data folder in my home folder /Users/israel/mongodata

cd
mkdir -p mongodata

Then I just execute the following command to register the path in mongodb

mongod --dbpath /Users/<your mac username folder>/mongodata

:)

@gonpeche
Copy link

gonpeche commented Aug 9, 2018

Hi,
Thanks for the detailed tutorial!
When I run this "mongod --dbpath /Users//mongodata" I get "mongod: command not found".
Do you know what could be happening?
Thanks!

@pedropauloportella
Copy link

Thanks for sharing this tutorial. It help me.

@smith288
Copy link

smith288 commented Jul 5, 2019

You have to restart the terminal for the path to refresh @gonpeche

@jrumley
Copy link

jrumley commented Feb 20, 2020

Awesome, thank you.

@karbagasurendran
Copy link

wow!!! It working. Thank you so much(நன்றி)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment