简体   繁体   中英

Access remote MongoDB database?

I've mostly worked with PHP/MySQL but I've now been handed a Node.js/MongoDB project on Github.

Having gone through a Mongo tutorial, I feel I understand the concept to a reasonable extent now, but I am still unsure how to do the most basic thing - view the Mongo database associated with the project.

In the config file, I found the following:

module.exports = {
    database: {
        url: 'localhost:27017/app_name'
    },

But seeing how I'm on a remote machine, how do I reach the database? Do I need to ask the previous dev for the DB so I can set it up locally?

Searching the code for the word mongo it only appears in packages.json so that's not a lot of help.

localhost:27017 

means the DB is in the local machine in which your are developing your app.

In your case, you have MONGO DB installed in your local machine and run the project.

Otherwise if you have a centralized DB then you have to configure that IP here as follows:

Also configure your mongodb.config of your remote DB to accept the connection from your local machine by changing the "BIND IP"

module.exports = {
    database: {
        url: 'yourRemoteIP:27017/app_name'
    },

Use a GUI tool, i would recommend MongoChef . All you need to do is when you start the server, just open this GUI and connect to DB. GAME ON!! You will be able to see your collections and you are ready to go. You can also run mongo query direct on the shell. It is a helpful tool for playing with your local DB.

PS I am considering you want to see your local DB.

You can access your DB through terminal as well, all upto you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM