PostgreSQL连接URL

PostgreSQL Connection URL

当主机是本地主机以外的其他计算机时,PostgreSQL连接URL是如何形成的?

我已经允许PostgreSQL接受来自外部的请求。


如果将Libpq绑定用于相应的语言,则根据其文档,URI的格式如下:

1
postgresql://[USER[:password]@][netloc][:port][/dbname][?param1=value1&...]

这是同一文档中的示例

1
2
3
4
5
6
7
8
postgresql://
postgresql://localhost
postgresql://localhost:5432
postgresql://localhost/mydb
postgresql://USER@localhost
postgresql://USER:secret@localhost
postgresql://other@localhost/otherdb?connect_timeout=10&application_name=myapp
postgresql://localhost/mydb?USER=other&password=secret


以下为我工作

1
const conString ="postgres://YourUserName:YourPassword@YourHost:5432/YourDatabase";


这是JDBC的文档,通用URL为" jdbc:postgresql:// host:port / database"

这里的第3章介绍了ADO.NET连接字符串,
常规连接字符串为Server=host;Port=5432;User Id=username;Password=secret;Database=databasename;

PHP文档在这里,一般的连接字符串是
host=hostname port=5432 dbname=databasename user=username password=secret

如果您正在使用其他产品,则必须告诉我们。


1
DATABASE_URL=postgres://{USER}:{password}@{hostname}:{port}/{database-name}

postgres的连接网址
句法:

1
"Server=host ipaddress;Port=5432;Database=dbname;User Id=userid;Password=password;

例:

1
"Server=192.168.1.163;Port=5432;Database=postgres;User Id=postgres;Password=root;

主机名或主机名将是远程服务器的IP地址,或者如果您可以通过计算机名通过网络访问它,则应该可以。