安装MongoDB 4.2

白昼怎懂夜的黑 提交于 2019-12-10 11:26:26

在Win10安装MongoDB4.2社区版

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

2.运行MongoDB安装程序

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

修改安装路径:

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

下面必须不能改动,直接next,否则改回去也不行

数据库路径(写进截图)、日志输出文件路径(写进截图)

下面可以选择是否安装图形化工具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个数据库

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

远程连接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 这一行注释掉也无法远程连接 )

 

 

 

 

 

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!