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:
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 |