Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to load Postgres sample database dvdrental

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.

like image 508
Pelumi Avatar asked Aug 16 '26 17:08

Pelumi


1 Answers

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

like image 171
BarzanHayati Avatar answered Aug 18 '26 07:08

BarzanHayati