How can I load a PostgreSQL SQL dump into my local database?

Problem: Importing a dump from my previous host on a local PostgreSQL setup fails.

For instance, executing:

psql -d new_db -f C:\backup\dump_data.sql

results in syntax errors. What approach works?

I encountered a similar challenge when trying to load a PostgreSQL dump into my local database. After some trial and error, I discovered that the problem was often due to a mismatch between the dump format and the import tool. If the dump was generated using a custom format, using pg_restore rather than psql solved the issue. It is important to verify that the dump file was created as a plain SQL file if you intend to import it via psql. Also, checking for any encoding discrepancies between the source and target databases helped me resolve syntax errors.

hey, have you tried checking if the dump is actually plain text? i had a similar issue and switching to pg_restore with matching formats didnt work as expected at first; maybe you could also verify the db version match. any other ideas on what could trigger syntax errors?