您的位置:首页 > 数据库 > Mongodb

MongoDB启动时出现errno:111 Connection refused错误的解决

2016-09-24 16:40 609 查看
问题描述:

MongoDB启动时报下列错误

[root@MongoDB ~]# mongo

MongoDB shell version: 2.6.1

connecting to: test

2014-05-25T18:47:24.021+0800 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused

2014-05-25T18:47:24.022+0800 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

exception: connect failed

解决方案:

1.查看保存数据库的目录是否存在

ls -ld /data/db
执行结果如下:

cuigaochongdeMacBook-Pro:~ root# ls -ld /data/db
drwxr-xr-x  7 root  wheel  238 Sep 24 16:21 /data/db

2.启动MongoDB的同时指定数据库保存在什么地方

mongod --dbpath /data/db
执行结果如下:

cuigaochongdeMacBook-Pro:~ root# mongod --dbpath /data/db
2016-09-24T16:37:28.410+0800 I JOURNAL  [initandlisten] journal dir=/data/db/journal
2016-09-24T16:37:28.410+0800 I JOURNAL  [initandlisten] recover : no journal files present, no recovery needed
2016-09-24T16:37:28.422+0800 I JOURNAL  [durability] Durability thread started
2016-09-24T16:37:28.422+0800 I CONTROL  [initandlisten] MongoDB starting : pid=624 port=27017 dbpath=/data/db 64-bit host=cuigaochongdeMacBook-Pro.local
2016-09-24T16:37:28.422+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2016-09-24T16:37:28.422+0800 I JOURNAL  [journal writer] Journal writer thread started
2016-09-24T16:37:28.422+0800 I CONTROL  [initandlisten] 
2016-09-24T16:37:28.422+0800 I CONTROL  [initandlisten] 
2016-09-24T16:37:28.422+0800 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2016-09-24T16:37:28.422+0800 I CONTROL  [initandlisten] db version v3.0.7
2016-09-24T16:37:28.422+0800 I CONTROL  [initandlisten] git version: nogitversion
2016-09-24T16:37:28.422+0800 I CONTROL  [initandlisten] build info: Darwin yosemitevm.local 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
2016-09-24T16:37:28.422+0800 I CONTROL  [initandlisten] allocator: system
2016-09-24T16:37:28.422+0800 I CONTROL  [initandlisten] options: { storage: { dbPath: "/data/db" } }
2016-09-24T16:37:28.431+0800 I NETWORK  [initandlisten] waiting for connections on port 27017
3.再次执行mongo

cuigaochongdeMacBook-Pro:~ cuigaochong$ mongo
MongoDB shell version: 3.0.7
connecting to: test
Server has startup warnings: 
2016-09-24T16:31:54.576+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2016-09-24T16:31:54.576+0800 I CONTROL  [initandlisten] 
2016-09-24T16:31:54.576+0800 I CONTROL  [initandlisten] 
2016-09-24T16:31:54.576+0800 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000


成功

本文出自
云人生
博客,请务必保留此出处http://ovcer.blog.51cto.com/1145188/1416906
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mongodb mac
相关文章推荐