技术

SCRAM authentication requires libpq version 10 or above 【升级PG扩展版本】

August 25, 2022

当程序错误日志中出现
pg_connect(): Unable to connect to PostgreSQL server: SCRAM authentication requires libpq version 10 or above
这代表着当前服务器postgresql-devel版本低于10,需要安装10或以上版本并且重新编译pdo_pgsql、pgsql、pq模块。

1.安装新版本,本文安装的是10

yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-    
latest.noarch.rpm -y
yum install postgresql10-devel -y

2.备份文件,修改指向到10版本,如果此步不做重新编译安装模块还是老版本的。

mv /usr/bin/pg_config /usr/bin/pg_config_9_bak
ln -s /usr/pgsql-10/bin/pg_config /usr/bin/

3.进入php安装包中重新编译安装模块

cd /data/tmp/php7/ext/pdo_pgsql
/data/app/php7/bin/phpize
./configure --with-php-config=/data/app/php7/bin/php-config
make clean
make && make install

cd /data/tmp/php7/ext/pgsql
/data/app/php7/bin/phpize
./configure --with-php-config=/data/app/php7/bin/php-config
make clean
make && make install

wget https://pecl.php.net/get/pq-2.2.0.tgz
cd pq-2.2.0
/data/app/php7/bin/phpize
./configure --with-php-config=/data/app/php7/bin/php-config
make clean
make && make install

附php.ini配置:
extension=raphf.so #安装pq模块前必须安装此模块
extension=pq.so
extension=pgsql.so
extension=pdo_pgsql.so

添加新评论