PostgreSQL: Export database to .sql file

pg_dump defaults to plain SQL export. both data and structure.

open command prompt and
run pg_dump -U username -h localhost databasename >> sqlfile.sql

Above command is preferable as most of the times there will be an error which will be something like – ...FATAL: Peer authentication failed for user ...

Leave a Comment