Skip to content

Instantly share code, notes, and snippets.

@laurenclark
Last active April 22, 2023 16:10
Show Gist options
  • Save laurenclark/c2e42d258675c3ccf991c681ca24d6fd to your computer and use it in GitHub Desktop.
Save laurenclark/c2e42d258675c3ccf991c681ca24d6fd to your computer and use it in GitHub Desktop.
Install mongodb on catalina
# copy from line 3 to 12 and paste in terminal
sudo mkdir -p /Users/$USER/mongo/db; # to ask for a password at the beginning
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"; # install homebrew
brew install wget; wget https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-4.2.1.tgz;
tar -zxvf mongodb-macos-x86_64-4.2.1.tgz;
cd mongodb-macos-x86_64-4.2.1;
sudo cp ./bin/* /usr/local/bin/; sudo ln -s ./bin/* /usr/local/bin/;
cd ..; rm -rf mongodb-macos-x86_64-4.2.1 mongodb-macos-x86_64-4.2.1.tgz;
mongod --dbpath=/Users/$USER/mongo/db; # start the mongo server
# ────────────────────────────────────────────────────────────────────────────────
# OPTIONAL - create a shorcut for the start server line
# 1) paste the following line in the ~/.zshrc (create if don't exists)
alias mongod_="mongod --dbpath=/Users/$USER/mongo/db;"
# 2) now you can use mongod_ for start the server with custom db folder location
mongod_
# Catalina stops writing in root directory so you need to chown
## Find username with `$ id -un`
sudo chown -Rv <YOURUSERNAME> /Users/$USER/mongo/db;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment