在 R 中使用 RPostgreSQL 包连接到 postgres 13 时出错。"authentication method 10 not supported"

Error connecting to postgres 13 using RPostgreSQL package in R. "authentication method 10 not supported"

我正在尝试使用 R studio 中的 RPostgreSQL 包连接到本地 postgres 13 服务器。我收到以下错误。我能够使用完全相同的代码连接到远程 postgres 9 服务器。下面的 link 给了我一些线索,但没有解决问题。它建议更新我的 psql 客户端,但它是最新的。这似乎与 postgres 使用的身份验证方法有关,但我并没有真正取得任何进展。任何帮助,将不胜感激。谢谢。

PostgreSQL authentication method 10 not supported

更新:我在 GitHub 上提出了一个问题,正如下面 Adrian Klaver 所建议的: https://github.com/tomoakin/RPostgreSQL/issues/112

# Restart R before running
library(RPostgreSQL)


# connection to the MIMIC database
mimic <- dbConnect(
  PostgreSQL(),
  dbname = "mimic",
  host = "localhost",
  port = 5432,
  user = "UN",
  password = "PW"
)

这是错误

Error in postgresqlNewConnection(drv, ...) : 
  RS-DBI driver: (could not connect postgres@localhost:5432 on dbname "mimic": authentication method 10 not supported
)

我的会话信息是……..

> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] dplyr_1.0.2       RPostgreSQL_0.6-2 DBI_1.1.0         stringr_1.4.0    

loaded via a namespace (and not attached):
 [1] dbplyr_1.4.4     crayon_1.3.4     assertthat_0.2.1 R6_2.4.1         lifecycle_0.2.0 
 [6] magrittr_1.5     pillar_1.4.4     stringi_1.4.6    rlang_0.4.8      rstudioapi_0.11 
[11] blob_1.2.1       generics_0.0.2   vctrs_0.3.4      ellipsis_0.3.1   tools_4.0.2     
[16] glue_1.4.1       purrr_0.3.4      compiler_4.0.2   pkgconfig_2.0.3  tidyselect_1.1.0
[21] tibble_3.0.1

我要说的是这个问题 RPostgreSQL_0.6-2

来自最近的变更日志:

2017-06-19 Tomoaki NISHIYAMA tomoakin@staff.kanazawa-u.ac.jp * new libpq from postgresql-9.6.3 and Makefiles generated on Sierra (macOS 10.12)

所以它使用的是 libpq(9.6.3) 不理解 SCRAM 身份验证的版本。您需要在此处提交问题:

https://github.com/tomoakin/RPostgreSQL/issues

获取更新驱动程序的项目。

2 个对我有用的选项。

  1. 我将 pg_hba.config 文件身份验证设置从 scram 更改为 md5,并且在重新启动 postgres 服务器后我能够 connect.I 实际上之前已经尝试过,但是我有 2我本地服务器上的 Postgres 版本并愚蠢地设法更改了错误的文件。

  2. Adrian Klaver 在评论中也建议使用 RPostgres(而不是 RPostgreSQL 包)。

我怀疑 RPostgreSQL 软件包会按照 GitHub 问题页面中的建议及时解决这个问题。

关注这里

https://github.com/tomoakin/RPostgreSQL/issues/112