MongoDB Data directory /data/db not found [duplicate]

匿名 (未验证) 提交于 2019-12-03 02:05:01

问题:

This question already has an answer here:

When I try to run Mongod in terminal I got this message :

2015-05-14T17:33:04.554+0700 I STORAGE  [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating 2015-05-14T17:33:04.554+0700 I CONTROL  [initandlisten] dbexit:  rc: 100 

and running mongo command :

MongoDB shell version: 3.0.3 connecting to: test 2015-05-14T17:34:26.679+0700 W NETWORK  Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused 2015-05-14T17:34:26.681+0700 E QUERY    Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed     at connect (src/mongo/shell/mongo.js:179:14)     at (connect):1:6 at src/mongo/shell/mongo.js:179 exception: connect failed 

I Have tried to change permision in /var/lib/mongodb and /var/log/mongodb, but still doesnt work, and I tried to uninstall and install mongodb again, but still the same problem exist. Anyone could help? Thanks

I'm using Ubuntu 14.04 LTS 64 bit

回答1:

MongoDB needs data directory to store data. Default path is /data/db

When you start MongoDB engine, it searches this directory which is missing in your case. Solution is create this directory and assign rwx permission to user.

If you want to change the path of your data directory then you should specify it while starting mongod server like,

mongod --dbpath /data/ --port 

This should help you start your mongod server with custom path and port.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!