Friday, October 17, 2014

How To Connect to a Remote MongoDB Server

How To Connect to a Remote MongoDB Server with MongoHub for Mac

There are three parts to this process: Changing the MongoDB Config to accept connections from remote hosts, Allowing port 27017 through your Firewall, and Configuring MongoHub.


Written: March 16, 2012
Applies to: Ubuntu 11.10, Mac OS X Lion
Here’s what you need to get started:
  1. Install MongoDB on your Server. There are a million tutorials out there, but here’s the one I used at mongodb.org.
    If you installed with apt-get install mongodb instead of  apt-get install mongodb-10gen here’s how to UNINSTALL the older version after shutting down gracefully so you don’t wind up with an infuriating mongod.lock file.

    Then go ahead and install the mongodb-10gen (latest stable) version.
  2. Download and install MongoHub for Mac OS X.

Secure MongoDB.

  1. Start the shell and add an administrative user for the server.

    Note: On my system, typing ./mongo doesn’t work, but plain mongo does.
  2. Authenticate, still in the shell.
  3. Configure a specific user for another database.
  4. Exit the MongoDB shell.
  5. Edit the mongodb.conf file to enable authentication.

  6. Uncomment this line.
  7. Restart MongoDB

Open up Port 27017 on your Firewall

This will be different for everyone. As an alternative, you can run MongoDB on a different port, maybe something that’s already open on your firewall. You can change the port by editing the mongodb.conf file and restarting the server.

Configure MongoHub

  1. Fire up MongoHub.
  2. Click the plus icon in the lower left to add a database.
  3. Fill out the information about your database.

That’s it! You can now browse your secure database!

No comments:

Post a Comment