Change MongoDB Default Data Directory

1. Stop mongoDb and Create the new data directory:

systemctl stop mongodb
mkdir /home/data

2. Copy the data from default to new data directory:

cp -rf /data/* /home/data/.

3. Edit /etc/mongod.conf and add dbPath:

systemLog:
   destination: file
   path: "/var/log/mongodb.log"
   logAppend: true
storage:
   dbPath: /home/data/db
   journal:
      enabled: true
processManagement:
   fork: true
net:
   bindIp: 10.0.0.1
   port: 27017
setParameter:
   enableLocalhostAuthBypass: false
security:
   authorization: enabled

4. Start Mongo DB

systemctl start mongodb

Be the first to comment

Leave a Reply

Your email address will not be published.


*