MongoDB 没有保存我分配给它的数据库路径。如何保存数据库路径?
我像这样设置我的数据库路径:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最佳实践是将所有启动参数存储在 mongod.conf yaml 文件中
并每次使用 mongo --config mongodb.conf 文件或作为服务启动 mongod 进程。
示例内容:
如果您不指定 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:
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