MongoDB 没有保存我分配给它的数据库路径。如何保存数据库路径?

发布于 2025-01-17 02:51:08 字数 340 浏览 3 评论 0原文

我像这样设置我的数据库路径:

mongod --dbpath /Users/dylan/development/mongodb/data/db

然后它连接到数据库并运行良好。但是一旦我退出并尝试再次启动 mongod 就会出现此错误:

Data directory /data/db not found. Create the missing directory or specify another path using (1) the --dbpath command line option

由于某种原因它没有保存 --dbpath

Im setting my dbpath like so:

mongod --dbpath /Users/dylan/development/mongodb/data/db

it then connects to the db and runs fine. But as soon as I exit and try to start mongod again it comes up with this error:

Data directory /data/db not found. Create the missing directory or specify another path using (1) the --dbpath command line option

for some reason it isn't saving the --dbpath

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

故事和酒 2025-01-24 02:51:08

最佳实践是将所有启动参数存储在 mongod.conf yaml 文件中
并每次使用 mongo --config mongodb.conf 文件或作为服务启动 mongod 进程。
示例内容:

storage:
  dbPath: /Users/dylan/development/mongodb/data/db

如果您不指定 dbPath 位置,则 mongod 进程将从默认 dbPath 位置( /data/db )启动,或者如果作为服务启动,则在位于 linux 的默认配置文件 /etc/mongod.conf 中找到 dbPath

It is a best practice to store all startup parameters in the mongod.conf yaml file
and start the mongod process every time with mongo --config mongodb.conf file or as a service.
example content:

storage:
  dbPath: /Users/dylan/development/mongodb/data/db

If you dont specify the dbPath location , the mongod process start with default dbPath location( /data/db ) or if started as service the dbPath found in default config file located in linux at /etc/mongod.conf

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文