PostgreSQL 连接 URL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3582552/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PostgreSQL Connection URL
提问by JII
How is the PostgreSQL connection URL formed, when the host is some other computer than the localhost?
当主机是本地主机以外的其他计算机时,PostgreSQL 连接 URL 是如何形成的?
I have allowed PostgreSQL to accept requests from outside.
我已经允许 PostgreSQL 接受来自外部的请求。
回答by Andrey
If you use Libpq binding for respective language, according to its documentationURI is formed as follows:
如果您为相应的语言使用 Libpq 绑定,根据其文档URI 形成如下:
postgresql://[user[:password]@][netloc][:port][/dbname][?param1=value1&...]
Here are examples from same document
以下是来自同一文档的示例
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
回答by Hemadri Dasari
The following worked for me
以下对我有用
const conString = "postgres://YourUserName:YourPassword@YourHost:5432/YourDatabase";
回答by gildniy
DATABASE_URL=postgres://{user}:{password}@{hostname}:{port}/{database-name}
回答by nos
Hereis the documentation for JDBC, the general URL is "jdbc:postgresql://host:port/database"
这里是JDBC的文档,一般的URL是“jdbc:postgresql://host:port/database”
Chapter 3 heredocuments the ADO.NET connection string,
the general connection string is Server=host;Port=5432;User Id=username;Password=secret;Database=databasename;
第 3 章这里记录了 ADO.NET 连接字符串,一般的连接字符串是Server=host;Port=5432;User Id=username;Password=secret;Database=databasename;
PHP documentation us here, the general connection string is
host=hostname port=5432 dbname=databasename user=username password=secret
PHP文档我们在这里,一般的连接字符串是
host=hostname port=5432 dbname=databasename user=username password=secret
If you're using something else, you'll have to tell us.
如果你正在使用其他东西,你必须告诉我们。
回答by Vinoth Shankar
the connection url for postgres syntax:
postgres 语法的连接 URL:
"Server=host ipaddress;Port=5432;Database=dbname;User Id=userid;Password=password;
example:
例子:
"Server=192.168.1.163;Port=5432;Database=postgres;User Id=postgres;Password=root;
回答by user1453137
host or hostname would be the i.p address of the remote server, or if you can access it over the network by computer name, that should work to.
主机或主机名将是远程服务器的 IP 地址,或者如果您可以通过计算机名称通过网络访问它,那应该可以。