【问题标题】:Yii2 postgres error - fe_sendauth: no password suppliedYii2 postgres 错误 - fe_sendauth: 未提供密码
【发布时间】:2016-02-03 10:46:14
【问题描述】:

我用的是 Yii2,数据库连接

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

我的数据库没有密码。我收到一个错误:SQLSTATE[08006] [7] fe_sendauth:没有提供密码。 如果我使用一些密码(只是假的,正如我所提到的,我没有密码),我会得到:password authentication failed for user "data-storage"

在 pg_hba.conf 我有我的域的记录:
host all all 172.28.3.70/32 trust
这对 PgAdmin 很有效。

【问题讨论】:

标签: postgresql yii2


【解决方案1】:

我想通了,我用的是localhost,而不是数据库所在的服务器IP

【讨论】:

    【解决方案2】:

    试试这个

    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
        ];
    

    或删除password

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-29
      • 2013-08-02
      • 1970-01-01
      • 1970-01-01
      • 2014-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多