Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to find the Mongodb credentials from the config file?

I’ve recently joined to a project that uses Mongodb. I’m a newbie to this database. I need to find the database credentials to get an export of it (as a backup) before everything.

The doc says, the connect() method would have these parameters:

connect(url, user, password)

But I don’t see that syntax in the real project. Here is the content of mongoose.js file:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

const mongoose = require('mongoose');

mongoose.Promise = global.Promise;
mongoose.connect(
  'mongodb://bpAdmin:Bp1400#@32.150.189.207:27017/bpDB?authSource=admin',
  {
    useCreateIndex: true,
    useFindAndModify: true,
    useNewUrlParser: true,
    useUnifiedTopology: true,
    autoIndex: true,
  }
);
mongoose.set('useCreateIndex', true);

module.exports = {
  mongoose,
};

(The IP and some other names just changed because of some security reasons)

Could you please tell me what’s the user and password and db name?

>Solution :

Check out the format in offical documentation on connection string,

mongodb://[username:password@]host1[:port1][,…hostN[:portN]][/[defaultauthdb][?options]]

So for your questions,

info value
username bpAdmin
password Bp1400#
db name used for auth admin
default db to connect to bpDB
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading