Each time I connect to a remote mongodb server, it is needed to write the host address of the mongo server.
In my situation, I connect only a single remote mongo. So, is there a way to set the default server address that make it possible to connect without passing host parameter each time?
connect('mongodb://localhost:27017/myapp'); This is the minimum needed to connect the myapp database running locally on the default port (27017). If connecting fails on your machine, try using 127.0. 0.1 instead of localhost .
The default dbpath for mongodb is /data/db .
hostname — the IP address of the MongoDB Server and the port number that the MongoDB service uses. ▪ username — the admin user name that you created to log in to the MongoDB Server. ▪ password — the admin password used to log in to the MongoDB Server.
To find the public IP address for any node in your cluster, use the nslookup tool from the command line. The IP address is shown in the Address portion of the output.
If you are on a *nix os you can use alias
(http://en.wikipedia.org/wiki/Alias_(command)):
alias mongo='mongo --host 127.0.0.1'
You might want to call you alias something else than mongo
though.
For the php driver, I can change the directive 'mongo.default_host = localhost' to 'mogno.default_host = REMOTEADDRESS'. By this change I no longer need to pass the host address. This is what I was looking for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With