无法连接到MongoDB errno:61 [英] Cannot connect to MongoDB errno:61
问题描述
我使用macports安装了MongoDB,并尝试运行mongo
命令以启动mongo shell.我收到以下错误:
I installed MongoDB using macports and tried running the mongo
command in order to start the mongo shell. I received the following errors:
warning: Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused
Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed
at src/mongo/shell/mongo.js:146
然后我运行mongod
并收到以下错误:
I then ran mongod
and received the following error:
$ [initandlisten] MongoDB starting : pid=11984 port=27017 dbpath=/data/db 64-bit host=Nikitas-MacBook-Air.local
$ [initandlisten]
$ [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
$ [initandlisten] db version v2.6.0
$ [initandlisten] git version: nogitversion
$ [initandlisten] build info: Darwin tennine-slave.macports.org 13.1.0 Darwin Kernel Version
13.1.0: Thu Jan 16 19:40:37 PST 2014; root:xnu-2422.90.20~2/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_55
$ [initandlisten] allocator: tcmalloc
$ [initandlisten] options: {}
$ [initandlisten] exception in initAndListen: 10296
*********************************************************************
ERROR: dbpath (/data/db) does not exist.
Create this directory or give existing directory in --dbpath.
See http://dochub.mongodb.org/core/startingandstoppingmongo
*********************************************************************
, terminating
$ [initandlisten] dbexit:
$ [initandlisten] shutdown: going to close listening sockets...
$ [initandlisten] shutdown: going to flush diaglog...
$ [initandlisten] shutdown: going to close sockets...
$ [initandlisten] shutdown: waiting for fs preallocator...
$ [initandlisten] shutdown: lock for final commit...
$ [initandlisten] shutdown: final commit...
$ [initandlisten] shutdown: closing all files...
$ [initandlisten] closeAllFiles() finished
$ [initandlisten] dbexit: really exiting now
我在哪里在根目录下创建/data/db
目录?当我运行mongo
时,第二个错误是errno:61
的原因吗?
Where do I create the /data/db
directory, at root? Would the second error be the reason for the errno:61
when I run mongo
?
推荐答案
是的,您将在根目录下创建/data/db
. MongoDB文档提出了以下创建命令: OS X mkdir -p /data/db
.
Yes, you would create /data/db
at root. The MongoDB Documentation suggests the following command for creation on OS X mkdir -p /data/db
.
关于第二个问题,也是.由于Mongo Daemon无法启动且未在监听,因此出现连接错误.
Regarding your second question, also yes. Since the Mongo Daemon failed to start and isn't listening you get the connection error.
MongoDB默认为/data/db
.您可以使用mongod
命令上的--dbpath
选项(也位于上面的doc链接上)覆盖默认值.
MongoDB defaults to /data/db
for the data directory. You can override the default using the --dbpath
option on the mongod
command (also on the doc link above).
这篇关于无法连接到MongoDB errno:61的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!