安装MongoDB 4.2,以及常见问题解决

在Win10安装MongoDB4.2社区版

1.下载MongoDB社区版 win64的.msi安装程序

2.运行MongoDB安装程序

一直next,在下面这一步,安装类型,选择 Custom(自定义),来指定我们自己合适的安装位置:

修改安装路径:

从MongoDB 4.0开始,可以在安装过程中将MongoDB设置为Windows服务,并在成功安装后启动MongoDB服务

下面的数据库路径、日志输出文件路径无法改动,直接next

下面可以选择是否安装图形化工具mongodb compass,勾选的话安装时间会比较长

 

 勾选mongodb compass的话安装时间会比较长

安装完成

安装完成后文件目录如下图

查看MongoDB服务,已经启动:

简单验证MongoDB是否安装成功,浏览器访问http://localhost:27017/,

页面上输出:It looks like you are trying to access MongoDB over HTTP on the native driver port. 就说明MongoDB的默认端口27017已经对外提供服务了

 

mongodb自带的3个数据库

-------------------------------------------------------------------------------------------------------------------------------------

问题1,MongoDB安装错误:The installer has encountered an unexpected error installing this package. This may indicate a problem with this package.The error code is 2503.

翻译:安装程序在安装此包时遇到意外错误。这可能表明此包有问题。错误代码是2503。

原因:

这种错误是因为window 10的机制,必须得使用管理员身份进行运行。

解决:

用管理员身份执行安装程序(win x —> a —> 安装文件全路径 —> enter),如下图:

-------------------------------------------------------------------------------------------------------------------------------------

问题2,远程连接MongoDB失败,报错Exception opening socket

原因:

mongodb.cfg配置文件中bindIp是127.0.0.1,127.0.0.1只允许本地连接,不接受远程连接mongodb

bindIp是什么?

bindIp is localhost, which forces the server to only listen for requests on the localhost IP. Only bind to secure interfaces that the application-level systems can access with access control provided by system network filtering (i.e. “firewall”).

bindIp若是localhost,这会强制服务器只监听 localhost 上的请求。仅绑定到应用程序级系统可以使用由系统网络过滤提供的访问控制(即“ 防火墙 ”)访问的安全接口。

mongod installed from official .deb and .rpm packages have the bind_ip configuration set to 127.0.0.1 by default.
mongod官方的.deb和.rpm安装包的bind_ip默认设置为127.0.0.1。

 解决:

必须把bindIp改为0.0.0.0( 把 bindIp:127.0.0.1 这一行注释掉也无法远程连接 )

 

The End

 

 

 

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值