虚拟机没办法连接MongoDB

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

1回答
好帮手慕小猿 2020-09-24 16:47:43

同学你好,先用如下命令启动试一下:

mongod --dbpath data/ --logpath log/mongo.log --port 27017 --bind_ip 0.0.0.0 --fork

http://img1.sycdn.imooc.com//climg/5f6c5d1409807aba06580081.jpg
如果我的回答解决了你的疑惑,请采纳,祝学习愉快~


  • 老师,还是不行,帮看下怎么弄 [imooc-user1@localhost ~]$ mongod --dbpath data/ --logpath log/mongo.log --port 27017 --bind_ip 0.0.0.0 --fork about to fork child process, waiting until server is ready for connections. forked process: 4302 ERROR: child process failed, exited with error number 1 To see additional information in this output, start without the "--fork" option. [imooc-user1@localhost ~]$ ^C [imooc-user1@localhost ~]$ mongod --dbpath data/ --logpath log/mongo.log --port 27017 --bind_ip 0.0.0.0 2020-09-24T16:57:01.889+0800 F CONTROL [main] Failed global initialization: FileNotOpen: Failed to open "/home/imooc-user1/log/mongo.log" [imooc-user1@localhost ~]$ mongo MongoDB shell version v4.0.20 connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb 2020-09-24T16:57:13.733+0800 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused : connect@src/mongo/shell/mongo.js:344:17 @(connect):2:6 exception: connect failed
    2020-09-24 16:59:19
  • 换成这个绝对路径也是不行,要怎么操作呢? [imooc-user1@localhost ~]$ mongod --dbpath E:/Mongodb/Server/4.4/data/ --logpath E:/Mongodb/Server/4.4/log/mongo.log --port 27017 --bind_ip 0.0.0.0 --fork about to fork child process, waiting until server is ready for connections. forked process: 4470 ERROR: child process failed, exited with error number 1 To see additional information in this output, start without the "--fork" option. [imooc-user1@localhost ~]$ mongod --dbpath E:/Mongodb/Server/4.4/data/ --logpath E:/Mongodb/Server/4.4/log/mongo.log --port 27017 --bind_ip 0.0.0.0 2020-09-24T17:05:19.917+0800 F CONTROL [main] Failed global initialization: FileNotOpen: Failed to open "/home/imooc-user1/E:/Mongodb/Server/4.4/log/mongo.log" [imooc-user1@localhost ~]$
    2020-09-24 17:06:48
  • 同学你好,同学可以删除mongodb 的db目录下的mongod.lock文件,重启mongodb即可
    2020-09-24 18:18:50
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
4.入门主流框架Scrapy与爬虫项目实战
  • 参与学习           人
  • 提交作业       107    份
  • 解答问题       1672    个

Python最广为人知的应用就是爬虫了,有趣且酷的爬虫技能并没有那么遥远,本阶段带你学会利用主流Scrapy框架完成爬取招聘网站和二手车网站的项目实战。

了解课程
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师