Re: restore question - Mailing list pgsql-general

From Adrian Klaver
Subject Re: restore question
Date
Msg-id b65cf6a7-130e-e3a9-1216-f5947bcabb4d@aklaver.com
Whole thread Raw
In response to Re: restore question  (Ronald Haynes <rhaynes74@gmail.com>)
Responses Re: restore question
List pgsql-general
On 7/19/22 9:44 AM, Ronald Haynes wrote:
> Thanks Ray, running
> 
> pSql -f backup-file.sql
> 
> 
> 
> psql: error: FATAL: database "rhaynes74" does not exist

No that is expected as you did not specify a database to connect to 
using -d <some_db>. In that case psql uses the OS user name you are 
running the command as for the database name per:

https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS

dbname

     The database name. Defaults to be the same as the user name. In 
certain contexts, the value is checked for extended formats; see Section 
34.1.1 for more details on those.

So change the command to:

psql -d postgres  -U <db_user> -f backup-file.sql

Where <db_user> is a database user that has the correct privileges to 
load/create the databases.

> 
> Which seems odd since rhaynes74 is a user not a database name in the file.
> 
> Sincerely,
> 
> Dr. Ronald D. Haynes
> Professor, Department of Mathematics and Statistics
> Chair, MSc and Phd Scientific Computing Programs
> Memorial University of Newfoundland



-- 
Adrian Klaver
adrian.klaver@aklaver.com



pgsql-general by date:

Previous
From: Marc Millas
Date:
Subject: Re: postgis
Next
From: Adrian Klaver
Date:
Subject: Re: postgis