0

Recently upgraded my PostgreSQL version from 10.x to 13 and i have came across a weird bug related to user authentication while accessing the DB.

These are the old credentials which i was using to connect with PostgreSQL 10.x version-

root

26_v9Fe},,6\Z3E?

But the same credentials when i created in PostgreSQL v13, i'm getting the well known authentication failure error in Java (using Java code to connect to Postgresql)-

org.postgresql.util.PSQLException: FATAL: password authentication failed for user root

The only difference in my PostgreSQL version was the encryption type- md5 was used with the 10.x version but the 13 version is using scram-sha-256.

Would be helpful if someone can provide an insight on this.

ravi ranjan
  • 143
  • 1
  • 4
  • In what sense is this random, does it not happen every time? – tgdavies Aug 19 '21 at 07:21
  • my bad, wanted to say strange. Happens with the postgresql 13 with the above mentioned specific password only. – ravi ranjan Aug 19 '21 at 07:32
  • Maybe password is ok, but root (remote) password login is not allowed anymore in some default settings? Or would that give a different error message? – wearego Aug 19 '21 at 07:35
  • When i change the above mentioned password in pgAdmin and in my Connector.java file, i'm able to connect via updated credentials successfully without any issues. But when i rollback to the mentioned credentials, the same error message pops up – ravi ranjan Aug 19 '21 at 07:37
  • 3
    You can't upgrade a password from md5 to scram by upgrading the server. If the password is still in md5 format but the hba now demands scram, that would explain the failure. – jjanes Aug 19 '21 at 08:22
  • Do you have your password in a Java string literal? – tgdavies Aug 19 '21 at 09:43
  • You do need to set the password again. See this [post](https://stackoverflow.com/questions/64316324/i-tried-to-change-postgresql-md5-to-scram-sha-256-and-i-get-fatal-password-authe/64317399#64317399) – JGH Aug 19 '21 at 13:23
  • @jjanes It's a fresh installation of PostgreSQL v13.x [not updated anything], i'm creating a fresh set of credentials via the pgAdmin with the above mentioned username and password. My issue is if i change the above mentioned password to something else, the connection is successfully established. But with above particular password only i'm unable to establish connection with PostgreSQL 13.x[scram-sha-256]. The older PostgreSQL v10.x[md5] had the same set of credentials and it works. – ravi ranjan Aug 25 '21 at 07:07
  • @tgdavies yes i'm using it as a string literal – ravi ranjan Aug 25 '21 at 07:08
  • Are you escaping the \ correctly? – tgdavies Aug 25 '21 at 08:42
  • What version of pgAdmin? – jjanes Aug 25 '21 at 15:20
  • @tgdavies i mean its put up in as a string. Are there any other alternative to pass on the password and username? – ravi ranjan Aug 29 '21 at 08:33
  • @jjanes pgAdmin 4 that comes prebundled with default Postgresql 13 installation – ravi ranjan Aug 29 '21 at 08:34
  • You need to show the exact Java code you have written. – tgdavies Aug 29 '21 at 23:22

0 Answers0