pg_dump -h localhost -U postgres -W -d mydb > mydb.sql
pg_dump -U postgres mydb > mydb.sql
sudo pg_dump -h <host> -u postgres <db_name> -Z 9 > <backup_file_name>.sql.gz
pg_dumpall -U postgres -h localhost -f pg12bak.sql
NB: you will be prompted to enter your password severally and to avoid that:
https://stackoverflow.com/questions/50404041/pg-dumpall-without-prompting-password
pg_dump --host localhost --port 5432 --username postgres --format plain --verbose --file "<abstract_file_path>" --table public.tablename dbname
Check
Native client configuration