So with and exhaustive searching and pouring through the documentation, I tried a lot of solutions and here is one I found that worked for me. 'This is a macOS solution'. Note: Rename '/what/ever/location' to your actual location, but I recommend keeping the data, db, bin, log.
When installing mongodb using homebrew (pre-requisites, install xcode).
$ brew install mongodb
The official documentation says it does not create a config file, so you have to create one and put in this location.
/etc/mongod.conf
Once created use your text editor( of choice) to insert this code. Mine is simplified, but mongo documentation has a complete list of what else to include. Mongo documentation storage options: Note: this code is written in .yaml or .yml so no tabs.
systemLog:
destination: file
path: "/what/ever/location/log/mongod.log"
logAppend: true
storage:
dbPath: "/what/ever/location/data/db"
indexBuildRetry: true
repairPath: "/what/ever/location/data/db/repairdb"
journal:
enabled: true
processManagement:
fork: true
net:
bindIp: 127.0.0.1
port: 27017
setParameter:
enableLocalhostAuthBypass: false
I put in some extra stuff like log and repair path it's your choice. Next alter your .bash_profile
with this line:
# MongoDB Aliases
alias mongod="mongod --dbpath /what/ever/location/bin"
While you there if you haven't done so update your environment variable $PATH where the mongod shell is located.
export PATH="/what/ever/location/bin:$PATH"
In your cli (of choice) run this line to check if worked:
$ mongod