On 02/13/2016 12:16 PM, Mick wrote:
> 
> Thank you both, I used pg_dumpall, but when I tried to restore it with
> 
> psql -f postgress_20160213 postgres
> 
> it complained that user 'michael' doesn't exist.  Then tried logged in as 
> root, whereby it complained that user 'root' doesn't exist.  Then I 'su - 
> postgres' and it restored the database.  Is this how I am supposed to restore 
> from a backup?
> 
> I only run postgres for KDEPIM's akonadi, which seems to work fine post-
> upgrade.  :-)
> 

That works sort of by accident. If you don't specify a username on the
command-line, psql will try to log you in to postgresql using your
system username -- "michael", for you. When you ran psql as root, it
tried to log you into postgresql as the "root" postgresql user, and he
doesn't exist.

The default admin user built-in to postgresql is called "postgres", so
if you just happen to run psql as the system "postgres" user, it will
try to log you in as "postgres" and it will work.

If you run "psql -U postgres" it should achieve the same thing. And if
you don't want to have to remember that, you can create a ~/.pgpass file
that says to always use the "postgres" database user:

  http://www.postgresql.org/docs/current/static/libpq-pgpass.html


Reply via email to