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…


…which I will edit using Vim

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

Edit the storage path

The file should look something like this….

  destination: file
  path: /usr/local/var/log/mongodb/mongo.log
  logAppend: true
  dbPath: /usr/local/var/mongodb

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.