-2

I have downloaded pg_dump data from DeepDive Open Datasets. It is a file with extension .sql and to my knowledge that is a text file with SQL commands in it to recreate the database. I'm trying to peruse the data. How do I set up a Postgres database to do that?

I tried to use pgAdmin4 to view the data. However, I'm not sure how to set up and add a new server to read the data. I'm not sure if that is the correct approach.

I would appreciate any guidance with this.

jzm5
  • 31
  • 4

1 Answers1

1

You would view the dump itself with a pager like more or less; such a dump is a plain text file with SQL statements.

To restore such a dump you need to use psql, the command line client:

psql -U postgres -d adatabase -f dumpfile.sql

pgAdmin cannot restore such a dump, because it contains COPY ... FROM STDIN statements intermixed with the data.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
  • I get `psql: error: could not connect to server: FATAL: role "postgres" does not exist` I have also run `initdb -U postgres -D /var/lib/postgresql/data` – jzm5 Aug 23 '20 at 21:46
  • 1
    If your superuser is not called `postgres`, use the appropriate name instead. But if the database cluster was created with the `initdb` you quote, the superuser would be called `postgres`, so it is obvious that your running cluster was not created with that `initdb` statement. Looks like you messed something up. – Laurenz Albe Aug 24 '20 at 02:00