【MongoDB学习笔记3】处理MongoDB连接错误
admin
2023-04-12 13:01:46
0

安装MongoDB后第一次启用shell登录

mongo

会出现一下的错误:

warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused

用一下命令查看以下相关的信息:

mongod –v

输出以下信息:

2014-12-31T22:39:39.586-0800 shardKeyTest passed   
2014-12-31T22:39:39.587-0800 isInRangeTest passed    
2014-12-31T22:39:39.587-0800 shardObjTest passed    
2014-12-31T22:39:39.588-0800 [DataFileSync] BackgroundJob starting: DataFileSync    
2014-12-31T22:39:39.604-0800 [initandlisten] MongoDB starting : pid=20666 port=27017 dbpath=/data/db 64-bit host=localhost.localdomain    
2014-12-31T22:39:39.605-0800 [initandlisten] db version v2.6.6    
2014-12-31T22:39:39.605-0800 [initandlisten] git version: 608e8bc319627693b04cc7da29ecc300a5f45a1f modules: enterprise    
2014-12-31T22:39:39.605-0800 [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013    
2014-12-31T22:39:39.605-0800 [initandlisten] build info: Linux ip-10-41-128-95 2.6.32-220.el6.x86_64 #1 SMP Wed Nov 9 08:03:13 EST 2011 x86_64 BOOST_LIB_VERSION=1_49    
2014-12-31T22:39:39.605-0800 [initandlisten] allocator: tcmalloc    
2014-12-31T22:39:39.605-0800 [initandlisten] options: { systemLog: { verbosity: 1 } }    2014-12-31T22:39:39.605-0800 [initandlisten] User Assertion: 10296:    
*********************************************************************     
ERROR: dbpath (/data/db) does not exist.      
Create this directory or give existing directory in --dbpath.       
See http://dochub.mongodb.org/core/startingandstoppingmongo    
*********************************************************************
2014-12-31T22:39:39.703-0800 [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    
2014-12-31T22:39:39.703-0800 [initandlisten] dbexit:    
2014-12-31T22:39:39.703-0800 [initandlisten] shutdown: going to close listening sockets...    
2014-12-31T22:39:39.703-0800 [initandlisten] shutdown: going to flush diaglog...    
2014-12-31T22:39:39.703-0800 [initandlisten] shutdown: going to close sockets...    
2014-12-31T22:39:39.704-0800 [initandlisten] shutdown: waiting for fs preallocator...    2014-12-31T22:39:39.704-0800 [initandlisten] shutdown: lock for final commit...    
2014-12-31T22:39:39.704-0800 [initandlisten] shutdown: final commit...    
2014-12-31T22:39:39.704-0800 [initandlisten] shutdown: closing all files...    
2014-12-31T22:39:39.704-0800 [initandlisten] closeAllFiles() finished    
2014-12-31T22:39:39.704-0800 [initandlisten] dbexit: really exiting now

查看默认的配置文档:

dbpath=/var/lib/mongo

 

重新加载配置文档:

mongod –f /etc/mongod.conf


 

再次登录后正常:

mongo

得到信息:

MongoDB shell version: 2.6.6   
connecting to: test    
Welcome to the MongoDB shell.    
For interactive help, type "help".    
For more comprehensive documentation, 
see            http://docs.mongodb.org/    
Questions? Try the support group            
               http://groups.google.com/group/mongodb-user    
>


相关内容

热门资讯

AI会取代哪些职业?多个AI意... 当前,人们日益担忧人工智能(AI)将影响就业市场。美国近期一项研究显示,多个人工智能模型在预测哪些职...
大疆Air 4无人机曝光,预估... IT之家 5 月 12 日消息,消息源 Igor Bogdanov 昨日(5 月 11 日)在 X ...
中核国电漳州能源原党委书记、董... 中核集团中核国电漳州能源有限公司原党委书记、董事长何辉涉嫌严重违纪违法,目前正接受中央纪委国家监委驻...
总投资1.85亿元,郑州市金水... 【大河财立方消息】 5月11日,金水区人民政府对金水区城市更新项目入库信息进行公示,公示期为2026...
特朗普访华期间是否会讨论台湾和... 澎湃新闻记者 聂舒翼 谢瑞强5月12日,外交部发言人郭嘉昆主持例行记者会。有记者就特朗普访华期间是否...
AI+教育,郑州航空港区成果亮... 【大河财立方 记者 程帅星】5月11日,由教育部、浙江省人民政府共同主办的2026世界数字教育大会在...
外交部:中方反对美国向中国台湾... 新华社北京5月12日电(记者万倩仪、冯歆然)外交部发言人郭嘉昆12日在例行记者会上就中美关系和台湾问...
外交部:亚太各国应擦亮眼睛,共... 新华社北京5月12日电(记者董雪、孙楠)外交部发言人郭嘉昆5月12日在例行记者会上回答相关问题时表示...
坚定不移沿着习近平总书记指引的... 吴敏杰(右一)和陈萍(左一),由班车结缘。湖北日报全媒记者 张诗秋 摄淅川到柴湖的班车。李栀子 卢晋...
热搜爆了!腾讯张军: 不会开发... 5月11日晚,“微信状态 访客记录”爆上热搜第一。 今天(5月12日),微信员工@客村小蒋发文回应:...