Mac で postgresql migration実施時、以下のエラーが発生し、
しばらくmigrationが滞ったので、対処方法を備忘として、残します。


エラー内容

v9.4.1 から v9.5.2 へのupgrade のため以下のコマンドを実行したところ、

pg_upgrade -v -d /usr/local/var/postgres9.4 -D /usr/local/var/postgres -b /usr/local/Cellar/postgresql/9.4.1/bin/ -B /usr/local/Cellar/postgresql/9.5.2/bin/

途中まではうまくいったものの、 connection to database failed: fe_sendauth: no password supplied
エラーとなりました。

------------------Running in verbose mode
Performing Consistency Checks
-----------------------------
Checking cluster versions                                   ok
Current pg_control values:

pg_control version number:            942
Catalog version number:               201409291--------------------------
........................
........................

Values to be changed:

First log segment after reset:        000000010000000000000002
"/usr/local/Cellar/postgresql/9.4.1/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "/usr/local/var/postgres9.4" -o "-p 50432 -b  -c listen_addresses='' -c unix_socket_permissions=0700 -c unix_socket_directories='/usr/local/Cellar/postgresql/9.4.1'" start >> "pg_upgrade_server.log" 2>&1

connection to database failed: fe_sendauth: no password supplied


原因

認証関連でダメでした。 v9.4.1 使用時は、md5 パスワード認証を指定していましたが、
pg_upgrade 実施時は、認証を外して オールOK にしないとコマンドが実行できないようです。


対処方法

pg_hba.conf ファイルの認証設定を以下のように変更しました。

  • /usr/local/var/postgres9.4/pg_hba.conf

    # "local" is for Unix domain socket connections only
    local   all             all                                     trust 
    # IPv4 local connections:
    host    all             all             127.0.0.1/32            trust
    # IPv6 local connections:
    host    all             all             ::1/128                 trust 
    

  • /usr/local/var/postgres/pg_hba.conf

    # TYPE  DATABASE        USER            ADDRESS                 METHOD
    # "local" is for Unix domain socket connections only
    local   all             all                                     trust 
    # IPv4 local connections:
    host    all             all             127.0.0.1/32            trust
    # IPv6 local connections:
    host    all             all             ::1/128                 trust
    # Allow replication connections from localhost, by a user with the
    

これでコマンドが実行できるようになりました。
以上です。


参考

コメント