2010-08-27 72 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;