linux - 如何从 linux 命令行更改 MongoDB dbPath?

标签 linux mongodb

我应该使用什么命令来更改安装在 linux 系统上的 MongoDB 的 dbPath 设置?默认设置位于 /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

最佳答案

您的意思是不使用编辑器更改 conf 文件吗?如果是,您可以使用“sed”

$ sed -i 's@/var/lib/mongodb@/your/new/directory/here@g' configfile

或者如果您只想更改 dbPath:

$ sed -i '/dbPath/s/:.*/: \/your\/new\/directory\/here' configfile

关于linux - 如何从 linux 命令行更改 MongoDB dbPath?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34635842/

相关文章:

python - Linux Mint,Os 脚本不适用于多个 Python 版本

linux - 运行 shell 脚本以在日志中附加日期的基本 Cron 作业,不起作用

c - 格式 '%lld' 需要类型 'long long int' ,但参数 4 的类型为 'int64_t'

node.js - 我应该如何使用 MEAN 堆栈进行后端设计?

MongoDB find() 查询在使用 limit() + sort() 时扫描文档两次(使用重复游标)?

ruby-on-rails - Ruby:无法在 Ubuntu 14.04 上将 gem 从 1.8.23 升级到 1.9.1

linux - 在 Debian 64 位上编译和链接 32 位应用程序

MongoDB bson.M 查询

python - 皮蒙戈 : to check if we have connected to MongoDB database

node.js - 我在连接 mongodb 和express 时遇到错误,我的终端疯了