Home:ALL Converter>How to change MongoDB dbPath from linux command line?

How to change MongoDB dbPath from linux command line?

Ask Time:2016-01-06T22:43:01         Author:Quincy Glenn

Json Formatter

What command should I use to change the dbPath setting of MongoDB installed on a linux system? The default settings are found in /etc/mongod.conf

storage:
  dbPath: /var/lib/mongodb
  journal:
    enabled: true
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log
net:
  port: 27017
  bindIp: 127.0.0.1

Author:Quincy Glenn,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/34635842/how-to-change-mongodb-dbpath-from-linux-command-line
Alex :

Did you mean change the conf file without a editor? If yes, you could use 'sed'\n\n$ sed -i 's@/var/lib/mongodb@/your/new/directory/here@g' configfile\n\n\nor if you want to change just dbPath:\n\n$ sed -i '/dbPath/s/:.*/: \\/your\\/new\\/directory\\/here' configfile\n",
2016-01-06T14:56:05
yy