Q
Q
Qubert2014-07-08 11:05:29
PHP
Qubert, 2014-07-08 11:05:29

How to remotely access MongoDB?

How to remotely connect to MongoDB?
I have a debian server with mongo. How can I connect to it remotely? I know that for this you need to create a user who will be allowed to do this ...
specifically, I need this in order to be able to connect using PDO to the database itself and work with it already

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Z
zed, 2014-07-08
@zedxxx

Check bind_ip parameter in your config. By default, when installing from deb packages, access from the outside is prohibited (ip 127.0.0.1 is registered). To open access, you must either delete this entry or write 0.0.0.0 there.
docs.mongodb.org/manual/reference/configuration-op...
net.bindIp
Type: string
Default: All interfaces. .. versionchanged:: 2.6.0 The deb and rpm packages include a default configuration file that sets {{role}} to 127.0.0.1.
Specifies the IP address that mongos or mongod binds to in order to listen for connections from applications. You may attach mongos or mongod to any interface. When attaching mongos or mongod to a publicly accessible interface, ensure that you have implemented proper authentication and firewall restrictions to protect the integrity of your database.
To bind to multiple IP addresses, enter a list of comma separated values.

I
iryndin, 2014-07-10
@iryndin

0) Change bind_ip to either 0.0.0.0 (all interfaces) or specifically to your external IP
2) Make sure the firewall allows connections to your external IP on port 27017 (default)
3) restart mongod

L
lega, 2014-07-20
@lega

You can also make an ssh tunnel in one command, so sometimes I do automatic dumps from a remote server.
You can also configure openvpn or the like.
These methods are better in terms of security and more convenient if the client has a dynamic ip.
PS: In mongodb, it is not recommended to use login + password authorization.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question