运行 Mongodb 时得到 NonExistentPath: Data directory/data/db not found., 终止 [英] When running Mongodb got NonExistentPath: Data directory /data/db not found., terminating
问题描述
执行时产生的错误 sudo mongod
执行
The error generated when executed sudo mongod
executed
2018-09-13T20:56:08.259+0530 I CONTROL [initandlisten] MongoDB 启动:pid=3419 port=27017 dbpath=/data/db 64-bit host=admin2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] db version v3.6.7
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] git 版本:2628472127e9f1826e02c665c1d93880a204075e2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] OpenSSL 版本:OpenSSL 1.0.1f 2014 年 1 月 6 日2018-09-13T20:56:08.260+0530 我控制 [initandlisten] 分配器:tcmalloc2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] 模块:无2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] 构建环境:2018-09-13T20:56:08.260+0530 我控制 [initandlisten] distmod: ubuntu14042018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] distarch: x86_642018-09-13T20:56:08.260+0530 我控制 [initandlisten] target_arch: x86_642018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] 选项:{}2018-09-13T20:56:08.312+0530 I STORAGE [initandlisten] initAndListen 中的异常:NonExistentPath:找不到数据目录/data/db.,正在终止2018-09-13T20:56:08.312+0530 I CONTROL [initandlisten] 现在退出2018-09-13T20:56:08.312+0530 I CONTROL [initandlisten] 关闭代码:100
2018-09-13T20:56:08.259+0530 I CONTROL [initandlisten] MongoDB starting : pid=3419 port=27017 dbpath=/data/db 64-bit host=admin
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] db version v3.6.7
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] git version: 2628472127e9f1826e02c665c1d93880a204075e
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] allocator:
tcmalloc
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] modules: none
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] build environment:
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] distmod: ubuntu1404
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] distarch: x86_64
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] target_arch: x86_64
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] options: {}
2018-09-13T20:56:08.312+0530 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2018-09-13T20:56:08.312+0530 I CONTROL [initandlisten] now exiting
2018-09-13T20:56:08.312+0530 I CONTROL [initandlisten] shutting down with code:100
我是 MEAN 堆栈应用程序开发的初学者,一直遇到这个错误.请帮我.提前致谢
I'm a beginner in MEAN stack application development and stuck with this error. Please help me. Thanks in advance
推荐答案
这个方案解决了我的问题
This solution solves my problem
将目录设为
Make a directory as
sudo mkdir -p/data/db
sudo mkdir -p /data/db
这将创建一个名为 db 的目录,然后尝试从命令开始
That will make a directory named as db and than try to start with commands
sudo mongod
sudo mongod
如果您在启动 mongod 时遇到其他错误或问题,您可能会发现问题
If you get another error or problem with starting mongod, You may find problem as
无法设置监听器:SocketException: Address already in use如果你发现另一个错误,而不是你必须通过在终端中键入
Failed to set up listener: SocketException: Address already in use If you find that another error than you have to kill the running process of mongod by typing to terminal as
ps ax | grep mongod
找到mongod运行的端口并杀死进程.
Find the mongod running port and kill the process.
sudo kill ps_number
另一种方法是在启动mongod时制作一个特定的端口
Another way is to make a specefic port when starting mongod as
sudo mongod --port 27018
这篇关于运行 Mongodb 时得到 NonExistentPath: Data directory/data/db not found., 终止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!