About a year ago I did write about how to use pg_restore to load a database dump. This is still my preferred approach, since it gives me more fine grained control of what to load from the dump. It's just that if you are handed a text based SQL dump, you will need something like psql to load the data into a database.

Here is how it works in plain shell:

$ createdb my_new_db
$ psql -d my_new_db < dump-to-import.sql

Note that I did not use any hostname or username here. This is how I load such a dump in my local development environment if I have to work with a pre-existing data set. Since it is a local setup, all communication is via sockets in the file system.

Check for -h and -U in the man page of psql in case you want to specify them.


Comments

comments powered by Disqus