2010-08-27 153 views
61

当主机是本地主机以外的其他计算机时,Postgres连接url是如何形成的?Postgres连接网址

我允许Postgres接受来自外部的请求。

+0

驱动程序?语言? – 2010-08-27 10:30:23

回答

11

Here是JDBC的文档,一般的URL是 “的jdbc:在PostgreSQL://主机:端口/数据库”

第3章here记录了ADO.NET连接字符串, 一般的连接字符串Server=host;Port=5432;User Id=username;Password=secret;Database=databasename;

PHP文件我们here,一般的连接字符串 host=hostname port=5432 dbname=databasename user=username password=secret

如果你使用别的东西,你必须告诉我们。

0

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

129

如果使用Libpq的形成有用于各自语言的结合,根据其documentation URI如下:从同一文档

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

下面是示例

postgresql:// 
postgresql://localhost 
postgresql://localhost:5433 
postgresql://localhost/mydb 
postgresql://[email protected] 
postgresql://user:[email protected] 
postgresql://[email protected]/otherdb?connect_timeout=10&application_name=myapp 
postgresql://localhost/mydb?user=other&password=secret 
+1

这为我工作postgres:// user:secret @ localhost:5432/mydatabasename – 2018-02-16 15:04:31

0

为postgres的 语法连接URL :

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

例如:

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