Importing files from pg_dump
For importing files generated by pg_dump command, use the command pg_restore, like that:
$ pg_restore -Uusername -hlocalhost -c -v -Fc -ddatabase < file.pg_dump
Options:
- -U: username
- -h: host
- -c: drop database before recreating
- -v: verbose mode
- -Fc: the archive is in the custom format of pg_dump
- -d: database
For more options look on page manpage by pg_restore.
$ man pg_restore
SQL files
In case you have a sql file to import, use this command:
$ psql -Uusername -hlocalhost -v -ddatabase < file.sql
That's all!