简体   繁体   中英

pg_restore: [archiver] input file appears to be a text format dump. Please use psql

I was trying to create a new database (analyses_db) on a remote server from a sql file by the command:

pg_restore -d analyses_db byoryn_resource.sql

I received the error message

pg_restore: [archiver] input file appears to be a text format dump. Please use psql.`

When I tried to follow the instruction: (from https://stackoverflow.com/a/40632316/15721796 )

To reload such a script into a (freshly created) database named newdb:
$ psql -d newdb -f db.sql

I received:

psql: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

I have no idea how to solve this, as a rookie. The SQL file should be alright as it is provided.

After the connection error being solved, I tried the command
sudo -u postgres psql db_name < 'file_path'
(from https://stackoverflow.com/a/26610212/15721796 )
which works just fine.
Hope this can help someone who has the same problem.
Also some useful doc here https://www.postgresql.org/docs/9.1/backup-dump.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM