3

I'm a newbie and new to Postgresql. I'm following a tutorial online and after downloading and extracting the dvdrental.zip into dvdrental.tar . I changed directory to my postgres bin location. And tried to run

pg_restore -U postgres -d dvdrental '/Users/macbookair/Downloads/dvdrental/dvdrental.tar'

But I got this error:

pg_restore: [archiver (db)] connection to database "dvdrental" failed: FATAL: role "postgres" does not exist

Meanwhile my dvdrental database has a postgres role.

dwir182
  • 1,539
  • 10
  • 20
Pelumi
  • 413
  • 2
  • 5
  • 13
  • Have you read, and tried, the accepted answer to [this question](https://stackoverflow.com/questions/15301826/psql-fatal-role-postgres-does-not-exist)? – Tony Mar 01 '19 at 00:07

1 Answers1

3

At first: you must create a database in SQL-Shell:

CREATE DATABASE newdvdrental;

look at first picture

Creating New DataBase

In the next step:

pg_restore --dbname=newdvdrental -U postgres --verbose C:\dvdrental\dvdrental.tar

look at second picture:

Restoring dvdrental.tar to new database

And by checking result in PgAdmin:

checking result

BarzanHayati
  • 637
  • 2
  • 9
  • 22