最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - password authentication failed with sequelize v4 replication - Stack Overflow

programmeradmin3浏览0评论

I am attempting to connect to my database(s) via replication. I have filled out the fields in the replication option in a variety of ways only to get the same error each time:

password authentication failed for user "my_local_system_username"

where somehow sequelize/pg thinks that I am trying to log in with my operating system user name???

Here is what I tried:

const serverParams = {
    user: auth.db.user,
    password: auth.db.password,
    port: 5432
};

const dbConfig = {
    options: {
        dialect: 'postgres',
        protocol: 'tcp',
        replication: {
            write: {},
            read: process.env.NODE_ENV === 'production' ?
                [
                    {
                        ...serverParams,
                        host: 'db1.lupoex'
                    },
                    {
                        ...serverParams,
                        host: 'db2.lupoex'
                    }
                ] :
                [
                    {
                        ...serverParams,
                        host: 'test.db.lupoex'
                    }
                ]
        },
        pool: {
            max: 5,
            min: 0,
            idle: 5000,
            acquire: 20000
        }
        //logging: function(query) {
        //    console.log(query)
        //}
    }
};

new Sequelize('database', null, null, dbConfig.options);

Thanks in advance, all ments/suggestions wele.

I am attempting to connect to my database(s) via replication. I have filled out the fields in the replication option in a variety of ways only to get the same error each time:

password authentication failed for user "my_local_system_username"

where somehow sequelize/pg thinks that I am trying to log in with my operating system user name???

Here is what I tried:

const serverParams = {
    user: auth.db.user,
    password: auth.db.password,
    port: 5432
};

const dbConfig = {
    options: {
        dialect: 'postgres',
        protocol: 'tcp',
        replication: {
            write: {},
            read: process.env.NODE_ENV === 'production' ?
                [
                    {
                        ...serverParams,
                        host: 'db1.lupoex.'
                    },
                    {
                        ...serverParams,
                        host: 'db2.lupoex.'
                    }
                ] :
                [
                    {
                        ...serverParams,
                        host: 'test.db.lupoex.'
                    }
                ]
        },
        pool: {
            max: 5,
            min: 0,
            idle: 5000,
            acquire: 20000
        }
        //logging: function(query) {
        //    console.log(query)
        //}
    }
};

new Sequelize('database', null, null, dbConfig.options);

Thanks in advance, all ments/suggestions wele.

Share Improve this question edited Nov 17, 2017 at 19:53 istrau2 asked Nov 16, 2017 at 17:20 istrau2istrau2 3677 silver badges16 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

Adding require('dotenv').config(); to the top of my config file fixed it for me.

More convo on the issue here: https://github./sequelize/cli/issues/641

I figured this out. It seems the config needs a username like so:

const serverParams = {
    user: auth.db.user,
    username: auth.db.user,
    password: auth.db.password,
    port: 5432
};
发布评论

评论列表(0)

  1. 暂无评论