找到配置文件,可能是以下位置:

/www/server/mongodb/config.conf

## content
systemLog:
  destination: file
  logAppend: true
  path: /www/server/mongodb/log/config.log
 
# Where and how to store data.
storage:
  dbPath: /www/server/mongodb/data
  directoryPerDB: true

  journal:
    enabled: true
# how the process runs
processManagement:
  fork: true
  pidFilePath: /www/server/mongodb/log/configsvr.pid
 
# network interfaces
net:
  port: 27017
#  bindIp: 127.0.0.1
  bindIp: 127.0.0.1 172.17.0.4
#  bindIpAll: true
 
#operationProfiling:
#replication:
#    replSetName: bt_main   
security:
  authorization: disabled
  javascriptEnabled: false

#sharding:
#    clusterRole: shardsvr

修改原来的bindIp,改为以” “分隔的多个IP(注意:mongodb 4.x以前是用”,”分隔)

另外,配置bindIpAll: true的话则代表所有ip均能访问(bindIp: 0.0.0.0也能达到同样效果),重启mongodb服务后生效。