Moving MongoDB's data folder?

When you start mongodprocess you provide an argument to it --dbpath /directory which is how it knows where the data folder is.

All you need to do is:

  1. stop the mongod process on the old computer. wait till it exits.
  2. copy the entire /data/db directory to the new computer
  3. start mongod process on the new computer giving it --dbpath /newdirectory argument.

The mongod on the new machine will use the folder you indicate with --dbpath. There is no need to "recognize" as there is nothing machine specific in that folder, it's just data.

Tags:

Mongodb