How to handle special characters in the password string of the connection string of a Postgresql URL?

Using the connection string of the Postgresql URL in the format:

postgresql://user:secret@localhost

How to handle special characters in this string (e.g. $ ) so that it really works when connected to my postgres database?

I tried just encoding the url, so for example, "test $" becomes "test% 24" ... but this seems to be a problem since I get the error "FATAL: password authentication failed" when trying to use it.

+4
source share
1 answer

. URI .

, :

  • URI postgres 9.2, 9.1, . , URI .

  • . :

- URI.

  • .

9.3:

sql> alter user daniel password 'p$ass';

$ psql 'postgresql://daniel:p$ass@localhost/test'

$ psql 'postgresql://daniel:p%24ass@localhost'

psql 'postgresql://daniel:pass@localhost/test'

: .

+6

Source: https://habr.com/ru/post/1538501/