Skip to content

Instantly share code, notes, and snippets.

@dpilafian
Last active February 19, 2024 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpilafian/b07722347bb296cb6f3b6c300869d256 to your computer and use it in GitHub Desktop.
Save dpilafian/b07722347bb296cb6f3b6c300869d256 to your computer and use it in GitHub Desktop.
Quickly stand up of a local instance of MongoDB for development (without installing anything)
#!/bin/bash
#################
# Start MongoDB #
# WTFPL #
#################
# https://gist.github.com/dpilafian/b07722347bb296cb6f3b6c300869d256
displayIntro() {
echo
echo "Start MongoDB"
echo "============="
abortMsg="[ABORT] Install MongoDB:\n brew tap mongodb/brew\n brew install mongodb-community"
which mongod || { echo "$abortMsg"; exit; }
echo
}
shellInstructions() {
echo "To run the console (MongoDB Shell):"
echo " $ mongosh"
echo
}
startDb() {
cd ~/apps/mongo
mongod --version
echo "Data storage..."
mkdir -p db-store
ls -d $(pwd)/db-store
du -sh db-store
echo
echo "Launching..."
echo "Use ^C to shutdown"
ulimit -n 1000 #prevent "soft rlimits too low" warning
mongod --dbpath db-store
}
displayIntro
shellInstructions
startDb
#!/bin/bash
#################
# Start MongoDB #
#################
# To make this file runnable:
# $ chmod +x *.sh.command
projectHome=$(cd $(dirname $0); pwd)
installFolder=~/apps/mongo
displayIntro() {
cd $projectHome
echo
echo "Install Start MongoDB"
echo "====================="
pwd
echo
}
installScript() {
cd $projectHome
chmod +x *.sh.command
mkdir -p $installFolder
cp -v mongodb-start.sh.command $installFolder
which mongod
mongod --version
echo
echo "To start mongoDB, run:"
echo " $installFolder/mongodb-start.sh.command"
echo
}
displayIntro
installScript
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment