pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: pg_dumpall restore question



On Tue, 12 Oct 2021 11:32:33 +0200
Adam <adam%netbsd.org@localhost> wrote:

> > Hi!
> > 
> > I'm doing postgresql backups with pg_dumpall.
> > When I restore them, all the guides on the net say to just use
> > 
> >     psql -f backupfile
> > 
> > but when I do that as pgsql user on NetBSD, I get
> > 
> >     psql: error: FATAL:  database "pgsql" does not exist
> > 
> > and my workaround was to do
> > 
> >     psql -d postgres -f backupfile
> > 
> > instead. Why is that necessary?
> > Thomas
> 
> `psql` has to connect to a database; the database name defaults to username and that doesn't exists in your case, so you have to provide an existing database name.

The portable way to do this is to use "template1". This is what
official documentation recommends. You can also use "postgres" without
any ill effects but some people like to drop the default db so it's not
as portable.


Home | Main Index | Thread Index | Old Index