Reputation: 349
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
Upvotes: 0
Views: 1098
Reputation: 1616
You can also specify the dbPath option when starting mongo like
mongod --dbpath /srv/mongodb/
if you don't want to mess with the config file. Say if you have two mongo data directories on one machine, you can start up mongo with different data this way. Or you could just open up the .conf file in a text editor and change it, or use the sed
approach by @mulatinho to change it.
Upvotes: 0
Reputation: 488
Did you mean change the conf file without a editor? If yes, you could use 'sed'
$ sed -i 's@/var/lib/mongodb@/your/new/directory/here@g' configfile
or if you want to change just dbPath:
$ sed -i '/dbPath/s/:.*/: \/your\/new\/directory\/here' configfile
Upvotes: 1