在使用MongoDB时,我们经常会使用可视化工具连接数据库以便直观的查询数据,默认安装好的MongoDB只能在本地连接,要想开启远程登录,我们可以编辑MongoDB的配置文件:
vim /etc/mongod.conf
bing_ip字段可指定IP,也可以绑定本地所有IP:
这样就可以远程连接了!
Note:系统不同定义方式不一样,本配置是基于Ubuntu16.04系统!CentOS7.5可以配置bindIpAll: true生效!MongoDB版本要求3.0及以上
CentOS7.5:
# network interfaces
net:
#port: 27017
port: 27666
bindIp: 0.0.0.0 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.
关注微信公众号: