[英]I can't connect to the postgresql database
该项目正在运行,使用 Java 并在服务器上旋转。 我正在尝试连接到 postgresql 数据库,但出现此错误:
FATAL: password authentication failed for user "postgres"
以下是文件 application.xml 中的设置
spring:
profiles:
active: @spring.profiles.active@
jpa:
hibernate:
ddl-auto: none
datasource:
initialization-mode: always
platform: convert
driver-class-name: org.postgresql.Driver
username: postgres
password: postgres
url: jdbc:postgresql://localhost:5432/mark_convert
jdbc-url: jdbc:postgresql://localhost:5432/mark_convert
liquibase:
change-log: classpath:db/changelog.xml
这是 Docker-compose 文件
postgres-converter:
container_name: postgres-converter
image: postgres:13.2-alpine
restart: unless-stopped
ports:
- "5435:5432"
environment:
- POSTGRES_USER=postgres
- POSTGRES_DB=converter
- POSTGRES_PASSWORD=postgres
volumes:
- ./postgres_converter_data:/var/lib/postgresql/data
如果有人更改了数据库中的密码,那么 Java 应用程序将无法使用该数据库吗?
我会给你另一个 liquibase 的文件,但它让我更加困惑,指示了完全不同的名称。
<createTable tableName="converter_history" schemaName="history"> <column name="id" type="BIGINT" autoIncrement="true"> <constraints primaryKey="true" nullable="false"/> </column> <column name="type" type="varchar(20)"/> <column name="pic_number" type="varchar(4)"/> <column name="part_number_oem" type="varchar(50)"/> <column name="date_added" type="timestamp" defaultValueComputed="current_timestamp"> <constraints nullable="false"/> </column> <column name="result" type="varchar(50)"> <constraints nullable="false"/> </column> </createTable>
也许您不允许使用密码进行连接。 确认pg_hba.conf
文件是否有以下内容。
/var/lib/pgsql/data/pg_hba.conf
# TYPE DATABASE USER ADDRESS METHOD
# IPv4 local connections:
host all all 127.0.0.1/32 md5
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.