比如我本机装了MongoDB并且开启了服务,没有任何其他设置,这个时候另一台机子直接连我机子用ip如192.168.1.33:27017即可。
但是现在我通过xshell连接到一台服务器,假设ip是192.168.1.4,登陆用户名root,密码123456,MongoDB也启动了服务,端口也是27017,但是别的机子通过连接192.168.1.4:27017连接不成功,需要如何设置服务器呢?这个时候如何带上用户密码。连接错误提示是目标计算机积极拒绝。
使用MongoVUE连接也不行,提示输入用户名密码,我填的是xshell连接服务器的用户名密码,MongoDB应该没设用户和密码。
巴扎黑2017-04-25 09:06:03
sudo netstat -nputl
tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN 1109/mongod
Took a look at the MongoDB service monitoring address, so if you use 192.168.1.4, the connection will not be connected and will be rejected. This is a single response
Add the following lines to the mongod file. If it already exists, please modify it
bind_ip = 0.0.0.0
In addition, if it is redhat, centos series, open the firewall port
iptables -A INPUT -p tcp -m tcp --dport 27017 -j ACCEPT
Temporarily turn off selinux
setenforce 0
怪我咯2017-04-25 09:06:03
The answer above is correct. There is a bind ip in the configuration file. For remote access, it needs to be changed to the external IP or the external IP of the internal network. Then open the corresponding port. As for client connection, if it is the latest version 3.0 or above, please refer to /q/1010000002776398