I have a dump from an SQL database, it is a .sql
file. I tried restoring it in pgAdmin but I get an error:
pg_restore: error: input file appears to be a text format dump. Please use psql.
Then I tried using the psql
CLI but it just lists my users and it doesn’t show any error or restores anything. I tried psql
with the command
psql grana < c:dump-grana.sql
and got the result on the image:
Also when I try to use the command psql -U [user] -d [dbname] -1 -f <filename>.sql
it returns the same as the image above.
2
Answers
If you have used the following
pg_dump
to create the dump fileThen use the following restore command:
You will have to expose the following variables
You’re trying to use
psql
from insidepsql
The picture you show is from inside psql. Your command is supposed to call it from the outside. Type
q
and hit enter to exitpsql
, then use your command from outside it. Currently,psql
is reading your input and:psql grana < c:
gets ignored. It’s accepted as unfinished statement without verifying it yetdu
gets executed asdu
meta-command describing available usersmp-grana.sql
gets ignored as accidental parameters todu
psql
gets a;
from you, it assumes you’re still typing out some long and strange set of statements and commands. It won’t try to verify anything else than the meta-commands until you finish.If you’ve tried that from outside
psql
and it’s still happening, it means you likely overwrote the contents of the file with its path by accident and nowpsql
is receiving literalc:dump-grana.sql
from inside the file. In that case, if you created the dump yourself, you’ll need to re-do it. Otherwise, get a fresh copy and try again: your command should work just fine as long as the contents of the.sql
file make sense.