We are switching hosts and the old one provided a SQL dump of the PostgreSQL database of our site.
Now, I\'m trying to set this up on a local WAMP server to test thi
Postgresql12
from sql file: pg_restore -d database < file.sql
from custom format file: pg_restore -Fc database < file.dump
You can do it in pgadmin3. Drop the schema(s) that your dump contains. Then right-click on the database and choose Restore. Then you can browse for the dump file.
I noticed that many examples are overcomplicated for localhost where just postgres user without password exist in many cases:
psql -d db_name -f dump.sql
Follow the steps:
\c db_name
\i path_of_dump
[eg:-C:/db_name.pgsql]That worked for me:
sudo -u postgres psql db_name < 'file_path'
psql databasename < data_base_dump
That's the command you are looking for.
Beware: databasename
must be created before importing.
Have a look at the PostgreSQL Docs Chapter 23. Backup and Restore.