【发布时间】:2016-04-15 05:50:50
【问题描述】:
我安装了两个版本的 postgresql,9.4 和 9.5。我正在使用 npm 的 pg 使用 postgres 连接字符串连接到服务器。在 CLI 中,我可以使用 --cluter 选项连接到 9.5,如下所示:psql --cluster 9.5/main。在 postgres 的 documentation for the connection string 中,它们显示您可以使用的查询字符串参数之一是 options:
options- 添加命令行选项以在运行时发送到服务器
我意识到这意味着服务器的配置参数,而不是客户端。尽管如此,我还是尝试构建连接字符串并包含集群选项以连接到 9.5:
postgres://user@localhost/db_name?options=--cluster%3D9.5%2Fmain
果然我得到了:psql: FATAL: unrecognized configuration parameter "cluster"
好的,这并不奇怪。但是,无论我做什么,我似乎都无法连接到 9.5。我什至将环境变量 PGCLUSTER 设置为适当的版本字符串,但我认为这只能从 CLI 读取(即:不是当服务器通过 unix 套接字或主机连接时)。
从通过localhost 连接到服务器的脚本连接到 9.5 服务器而不是 9.4 的最简单方法是什么?
【问题讨论】:
标签: node.js postgresql database-connection