Node.js 每当我重新启动Ubuntu服务器时,mongodb需要我为mongod.conf文件提供路径。为什么?

Node.js 每当我重新启动Ubuntu服务器时,mongodb需要我为mongod.conf文件提供路径。为什么?,node.js,mongodb,Node.js,Mongodb,出于某种原因,每次通过运行以下命令重新启动服务器时,我都需要fork mongod.conf: mongod --config /etc/mongod.conf 我可以看出,当我重新启动服务器并运行mongod时,我收到以下消息: 2020-09-03T14:49:33.713+0000 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db

出于某种原因,每次通过运行以下命令重新启动服务器时,我都需要fork mongod.conf:

    mongod --config /etc/mongod.conf
我可以看出,当我重新启动服务器并运行
mongod
时,我收到以下消息:

    2020-09-03T14:49:33.713+0000 I  STORAGE  [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found. Create the missing directory or specify another path using (1) the --dbpath command line option, or (2) by adding the 'storage.dbPath' option in the configuration file., terminating
有没有一种方法可以让mongodb“读取”配置文件,而无需我在每次重新启动服务器时将其分叉