当主机不是本地主机时,PostgreSQL 连接字符串(URL postgres://...
)的格式是什么?
postgres://postgres:123456@127.0.0.1:5432/dummy
如果你对各自的语言使用 Libpq 绑定,根据它的 documentation URI 形成如下:
postgresql://[user[:password]@][netloc][:port][/dbname][?param1=value1&...]
以下是来自同一文档的示例
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
以下对我有用
const conString = "postgres://YourUserName:YourPassword@YourHostname:5432/YourDatabaseName";
The URI scheme designator can be either postgresql:// or postgres://
从这里:postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING
ping hostname
获取 IP 地址。
DATABASE_URL=postgres://{user}:{password}@{hostname}:{port}/{database-name}
Here 是 JDBC 的文档,一般 URL 是“jdbc:postgresql://host:port/database”
第 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
如果您使用其他东西,您必须告诉我们。
UseNpgsql()
。我有点困惑是应该是那个还是 postgres:// URL(我也将其视为“postgresql://”)
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;
server.address=10.20.20.10
server.port=8080
database.user=username
database.password=password
spring.datasource.url=jdbc:postgresql://${server.address}/${server.port}?user=${database.user}&password=${database.password}
不定期副业成功案例分享
postgresql://localhost/mydb?user=other&password=secret
成功了