当主机不是本地主机时,PostgreSQL连接字符串(URL postgres://…)是什么格式?
当前回答
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}
其他回答
DATABASE_URL=postgres://{user}:{password}@{hostname}:{port}/{database-name}
如果对各自的语言使用Libpq绑定,根据其文档,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
有些人似乎误读了数据库名作为服务器名和主机作为postgresql服务器?主机上有一个postgresql服务器,该服务器上有一个数据库。还是我遗漏了什么?
postgresql: / / my_host及服务器= my_postgresql_server ?用户= my_user&port = my_port&password = my_password&database = my_database
例子:
My_host:可以是“localhost”(但这不在问题中)或主机的IP地址。
postgresql: / / my_host / &server = postgres ?用户= postgres&port 5432&password = postgres&database = test_db
为我工作在Python sqlalchemy和postgresql localhost运行。需要sqlalchemy、postgresql和psycopg2才能使其工作。
PS:这个问题是关于postgres的://…URL,但这在这里不起作用。相反,你需要postgresql,在Python中最后运行的是方言+驱动程序(参见数据库url) = postgresql+psycopg2,而不必像这样编写。
下面的方法对我很有效
const conString = "postgres://YourUserName:YourPassword@YourHostname:5432/YourDatabaseName";
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}
推荐文章
- 如何连接列在Postgres选择?
- 将varchar字段的类型更改为整数:"不能自动转换为整数类型"
- PostgreSQL可以索引数组列吗?
- 什么是数据库池?
- PostgreSQL:角色不允许登录
- 如何查找Postgres / PostgreSQL表及其索引的磁盘大小
- 是使用各有一个模式的多个数据库更好,还是使用一个数据库有多个模式更好?
- 如果字符串包含
- 对于PostgreSQL表来说,多大才算太大?
- 将一列的多个结果行连接为一列,按另一列分组
- 使用pgadmin连接到heroku数据库
- 在PostgreSQL中快速发现表的行数
- 更改varchar列的大小为较低的长度
- 如何首次配置postgresql ?
- 数据库性能调优有哪些资源?