在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