0

I use Yii2, db connection

'db' => [
    'class' => 'yii\db\Connection',
    'dsn' => 'pgsql:host=localhost;dbname=data-storage',
    'username' => 'data-storage',
    'password' => '',
    'charset' => 'utf8',
]

My database does not have a password. I got an error: SQLSTATE[08006] [7] fe_sendauth: no password supplied. If I use some password (just fake, as I mentioned I don't have it) I'm getting: password authentication failed for user "data-storage"

In pg_hba.conf I have a record for my domain:
host all all 172.28.3.70/32 trust
Which works fine for PgAdmin.

Sergey Onishchenko
  • 6,943
  • 4
  • 44
  • 51

2 Answers2

0

I figured it out, I have used localhost instead of the server IP where the database is located.

Sergey Onishchenko
  • 6,943
  • 4
  • 44
  • 51
0

try this

return [
        'class' => 'yii\db\Connection',
        'dsn' => 'pgsql:host=localhost;dbname=db_name', 
        'username' => 'db_username',
        'password' => NULL,
        'charset' => 'utf8',
        'schemaMap' => [
          'pgsql'=> [
            'class'=>'yii\db\pgsql\Schema',
            'defaultSchema' => 'public' //specify your schema here
          ]
        ], // PostgreSQL
    ];

or remove password.

sxn
  • 157
  • 1
  • 7