4

I'm using Spring application and stack is like: Java 11, Spring Boot 2.2.1.RELEASE.

(technology versions may vary here) 

When I try to connect to the database via Data Source using Intellij IDEA, I get always the issue like:

The specified database user/password combination is rejected:
[28P01] FATAL: password authentication failded for user 'postgres'

enter image description here

How can I fix it?

To be noticed: this answer is similar, but not related to:

Unable to connect from Intellij to mySql running in docker container - "specified database user/password combination is rejected"

invzbl3
  • 5,872
  • 9
  • 36
  • 76

2 Answers2

1

To fix it:

you need to check your application.properties file and change the value of user password on line:

spring.datasource.password=your_password

The cause of issue is:

your value of the property spring.datasource.password in application.properties

does not match the user password what was selected by default during installing your database system.

E.g. more specifically on the step "Enter the password for the database superuser (postgres)":

enter image description here

To clarify: provided example is for PostgreSQL, but it can be another database system.

invzbl3
  • 5,872
  • 9
  • 36
  • 76
1

Edit: this assumes you run Linux

if the other answer provided by invzbl3 doesn't work, check out this solution, it worked for me. Make sure to restart afterwards.

https://docs.fedoraproject.org/en-US/quick-docs/postgresql/#_initial_configuration

If you’re getting ident errors from your app you’ll probably need to perform the accepted solution described at https://serverfault.com/questions/406606/postgres-error-message-fatal-ident-authentication-failed-for-user?newreg=a4fdc3e21349449985cc65b82399c5b4

(if you don't have nano, just use any other text editor)

sudo nano /var/lib/pgsql/data/pg_hba.conf and edit host all all 127.0.0.1/32 ident to host all all 127.0.0.1/32 md5.

This should allow most applications to connect with username/password.

jpkhawam
  • 41
  • 3