MongoDB - changing data directory name changes data
As per MongoDB documentation here To use an alternate dbpath, specify the path in the configuration file (e.g. C:\mongodb\mongod.cfg) or on the command line with the --dbpath option.


  Default: /data/db on Linux and macOS, \data\db on Windows


The directory where the mongod instance stores its data.

Changed in version 3.0: The files in --dbpath must correspond to the storage engine specified in --storageEngine. If the data files do not correspond to --storageEngine, mongod will refuse to start.

--directoryperdb

Uses a separate directory to store data for each database. The directories are under the --dbpath directory, and each subdirectory name corresponds to the database name.

Changed in version 3.0: To change the --directoryperdb option for existing deployments, you must restart the mongod instances with the new --directoryperdb  value and a new data directory (--dbpath ), and then repopulate the data.


For standalone instances, you can use <a
href="https://docs.mongodb.com/v3.2/reference/program/mongodump/#bin.mongodump" rel="nofollow noreferrer">mongodump
on the existing instance, stop the instance, restart with the new <a
href="https://docs.mongodb.com/v3.2/reference/program/mongod/#cmdoption-mongod-directoryperdb" rel="nofollow noreferrer">--directoryperdb
value and a new data directory, and use <a
href="https://docs.mongodb.com/v3.2/reference/program/mongorestore/#bin.mongorestore" rel="nofollow noreferrer">
mongorestore to populate the new data directory.
For replica sets, you can update in a rolling manner by stopping a
secondary member, restart with the new <a
href="https://docs.mongodb.com/v3.2/reference/program/mongod/#cmdoption-mongod-directoryperdb" rel="nofollow noreferrer">--directoryperdb
value and a new data directory, and use <a
href="https://docs.mongodb.com/v3.2/core/replica-set-sync/#replica-set-initial-sync" rel="nofollow noreferrer">initial
sync to populate the new data directory. To update all members,
start with the secondary members first. Then step down the primary,
and update the stepped-down member.