IT Base of Knowledge's Weblog

June 23, 2008

Export / Import PostgreSQL database

Filed under: Database,PostgreSQL — itbdc @ 12:55 pm

Export a database

su - postgres
pg_dump <database_name> > database_name.pgdump

Import a database

cat database_name.pgdump | psql -d database_name

For all database

pg_dumpall -o > db_all.out
psql -e template1 < db_all.out

1 Comment »

  1. This post saved my day. Far superior than phppgadmin. 🙂

    Just a note, you can skip “su – postgres” if you have a postgres user with the same username as your shell account. Then you’ll have your databases automatically owned by you also.

    Comment by Lilleman — November 19, 2009 @ 3:14 pm | Reply


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.