I try to connect my Spring-Boot-Application with new PostgreSQL USER (named : localX_deletion), but when i run it, that return me FlywaySqlException :
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.internal.exception.FlywaySqlException: Unable to obtain connection from database: FATAL: password authentication failed for user "localX_deletion"
SQL State : 28P01 Error Code : 0 Message : FATAL : password authentication failed for user "localX_deletion"
I dont understand because i can connect with this user in command-line : psql -U localX_deletion -h localhost and when i specify in spring.datasource another account the application run as excepted.
How i create Database/Role:
CREATE USER localx_deletion;CREATE DATABASE localx_deletion OWNER localx_deletion;ALTER USER localx_deletion WITH ENCRYPTED PASSWORD 'localx_deletion';ALTER DATABASE localx_deletion OWNER TO localx_deletion;GRANT ALL PRIVILEGES ON DATABASE localx_deletion TO localx_deletion;
What i have already tried to fix it:
For each tasks bellow i have restart postgresql service.
- Update password/name role.
- Delete all and re-create all.
- Setting in pg_hba.conf local and host as trust (that works but i dont like update this file, because the old config work fine with the others roles/databases).
- Purge, remove and reinstall Postgresql
Someone have an idea for fix it please ?
\du - List of roles
Role name | Attributes | Member of
------------------------+------------------------------------------------------------+-----------
localx | Create DB | {}
localx_standalone | Create DB | {}
localx_standalone_test | Create DB | {}
localx_deletion | Create DB | {}
localx_test | Create DB | {}
postgr
\l - List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
------------------------+------------------------+----------+-------------+-------------+-----------------------------------
localx | postgres | UTF8 | fr_FR.UTF-8 | fr_FR.UTF-8 | =Tc/postgres +
| | | | | postgres=CTc/postgres +
| | | | | localx=CTc/postgres
localx_standalone | localx_standalone | UTF8 | fr_FR.UTF-8 | fr_FR.UTF-8 |
localx_standalone_test | localx_standalone_test | UTF8 | fr_FR.UTF-8 | fr_FR.UTF-8 |
localx_deletion | localx_deletion | UTF8 | fr_FR.UTF-8 | fr_FR.UTF-8 | =Tc/localx_deletion +
| | | | | localx_deletion=CTc/localx_deletion
localx_test | localx_test | UTF8 | fr_FR.UTF-8 | fr_FR.UTF-8 |
postgres | postgres | UTF8 | fr_FR.UTF-8 | fr_FR.UTF-8 |
template0 | postgres | UTF8 | fr_FR.UTF-8 | fr_FR.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | fr_FR.UTF-8 | fr_FR.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
pg_hba.conf
# Database administrative login by Unix domain socket
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
Operating System : Ubuntu 20.04.1 LTS (Focal Fossa), Postgresql : 12