Postgresql – Cannot import database exported by phpPgAdmin

pg-dumpphppgadminpostgresql

I have exported database with phpPgAdmin tool – format sql, structure and data.

When I try to import this sql using:

psql command \i filename.sql

After some time (file is 2GB) I get following error:

ERROR: unterminated quoted string at or near ".. , '\x25504… "

with "arrow" pointing to \x.

Looks like \ is making a problem here…

Best Answer

Looking at this tutorial, seems like phpPgAdmin make a call for pg_dump to export the data.

To process plain files with psql, you must use the -foption, eg:

psql \
  -U postgres  \
  -d database_name \
  -f phppgadmin_dump_file.sql

I strongly recommend using pg_dump manually with the option --format=custom to make the restore more flexible (and use the tool pg_restore).

Please, take a look at this URL to restore de file using phpPgAdmin itself: