找不到MongoDB数据目录/data/db [英] MongoDB Data directory /data/db not found

查看:275
本文介绍了找不到MongoDB数据目录/data/db的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在终端中运行Mongod时,出现以下消息:

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

并运行mongo命令:

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

我尝试更改/var/lib/mongodb和/var/log/mongodb中的渗透,但仍然无法正常工作,我尝试再次卸载并安装mongodb,但仍然存在相同的问题. 有人可以帮忙吗?谢谢

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

我正在使用Ubuntu 14.04 LTS 64位

I'm using Ubuntu 14.04 LTS 64 bit

推荐答案

MongoDB需要数据目录来存储数据. 默认路径为/data/db

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

启动MongoDB引擎时,它将搜索此目录,该目录在您的情况下不存在.解决方案是创建此目录并为用户分配rwx权限.

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.

如果要更改数据目录的路径,则应在启动mongod服务器之类的时候指定它,

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

mongod --dbpath /data/<path> --port <port no> 

这应该有助于您使用自定义路径和端口启动mongod服务器.

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

这篇关于找不到MongoDB数据目录/data/db的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆