'Set sslmode=allow with pg_dump

I need to specify sslmode=allow when using psql to connect to my PostgreSQL DB, like: psql sslmode=allow -h localhost -p 5432 otherwise I get server does not support SSL, but SSL was required

I tried specifying the same option to pg_dump but it doesn't recognize the option.

How do I specify sslmode to pg_dump?



Solution 1:[1]

You need to use the environment variable PGSSLMODE like this:

PGSSLMODE=allow pg_dump -h localhost -p 5432

Solution 2:[2]

see https://dba.stackexchange.com/a/227805

pg_dump "port=<port> host=<host> user=<user> dbname=<db> sslcert=<cert> sslkey=<key> sslrootcert=<ca.crt> sslmode=allow" -f <file>      

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 qwertzguy
Solution 2