phpでpostgresのDBに接続する際のエラーに対処
2024年08月14日
EC-CUBEの2.1系で、インストールする際に、データベース作成のところで以下のエラーが出ました
MDB2 Error: connect failed [Error message: unable to establish a connection
phpで、postgresのDBに接続する際に、以下のようなエラーが出ました
Warning: pg_connect(): Unable to connect to PostgreSQL server: authentication method 10 not supported in ~
色々調べていると、phpが入れているバージョンが古く(5.6.4)、postgresのパスワードの暗号化のscram-sha-256に対応していなかった模様。
以下の方法で対応
pg_hba.confを編集
local all all scram-sha-256
↓
local all all md5
postgresql.sqlを編集
以下の設定に変更
password_encryption = md5
上記の2つのpostgresのファイルを編集後、postgresのサービスの再起動
その後、postgresのDBのパスワードを変更
ALTER USER username WITH PASSWORD ‘your_password’;
上記の後、接続することで無事接続することができるようになりました!