Changing mongo’s db location

Stoping mongo

If its already running, stop it

brew services stop mongo

If all goes well, it should return something like this

Stopping `mongodb`... (might take a while)
==> Successfully stopped `mongodb` (label: homebrew.mxcl.mongodb)

Locate the mongo config file and open it

should be here…

/usr/local/etc/mongo.conf

…which I will edit using Vim

sudo vim /usr/local/etc/mongo.conf

Edit the storage path

The file should look something like this….

systemLog:
  destination: file
  path: /usr/local/var/log/mongodb/mongo.log
  logAppend: true
storage:
  dbPath: /usr/local/var/mongodb
net:
  bindIp: 127.0.0.1

Line 6 is the one we are after, change that to the location you want.

dbPath: /my/new/path/is/here

Save the file and close it.

Start mongo again

brew services start mongo

If everything goes well, Mongo should have added a whole bunch of files to the new directory.