Warning: pg_connect(): Unable to connect to PostgreSQL server: authentication method 10 not supported in解决方法

[复制链接]
查看4526 | 回复0 | 2020-12-3 08:59 | 显示全部楼层 |阅读模式
Warning: pg_connect(): Unable to connect to PostgreSQL server: authentication method 10 not supported in....php操作pgsql数据库的时候报错,是什么情况呢?网上搜索了很多方法,都尝试过了,都不见效,其实相对他们那时候可能会见效,只是时间长了,php也升级了,pgsql数据库也升级了,导致按照教程修改也是不起作用了,最新解决方法,有些还是可以尝试下,例如:在我的电脑右键管理-找到服务-找到postgresql服务,右键启动即可。

Warning: pg_connect(): Unable to connect to PostgreSQL server: authentication method 10 not supporte ...

Warning: pg_connect(): Unable to connect to PostgreSQL server: authentication method 10 not supporte ...

环境拓展啥都有就是无法连接数据库:

Warning: pg_connect(): Unable to connect to PostgreSQL server: authentication method 10 not supporte ...

Warning: pg_connect(): Unable to connect to PostgreSQL server: authentication method 10 not supporte ...


不是是用phpstudy小皮环境集成包还是wamp集成包还是其他环境搭建的php都可以实现操作pgsql数据库。
测试的php语法如下:
  1. $dbconn = pg_connect("host=localhost port=5432 dbname=postgres user=postgres password=mima") or die('Could not connect: ' . pg_last_error());
  2. var_dump($dbconn);
复制代码


解决方法如下:
[sell=50,2]最终经过排查发现是postgresql版本太高,而php对应版本太低导致无法连接,建议更换如图所示版本即可解决问题

Warning: pg_connect(): Unable to connect to PostgreSQL server: authentication method 10 not supporte ...

Warning: pg_connect(): Unable to connect to PostgreSQL server: authentication method 10 not supporte ...

[/sell]

附带两个封装好php操作pgsql数据库的干货文件,修改配置即可使用。 php链接pgsql数据库文件.zip (1.92 KB, 下载次数: 0, 售价: 5 丢币)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

UID
1
贡献
387
丢币
38902
主题
4607
回帖
116
注册时间
2018-9-25
最后登录
2024-4-16