Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

database user "postgres" is not the install user

I'm trying to upgrade postgres from 9.5 to 9.6. brew upgrade postgresql succeeds, but when running

pg_upgrade -b /usr/local/Cellar/postgresql/9.5.3/bin/ -B /usr/local/Cellar/postgresql/9.6.1/bin/ -d /usr/local/var/postgres -D /usr/local/var/postgres9.6 -U postgres

I get an error

Performing Consistency Checks
-----------------------------
Checking cluster versions                                   ok
Checking database user is the install user
database user "postgres" is not the install user
Failure, exiting

when trying without -U postgres at the end it gets even weirder

Performing Consistency Checks
-----------------------------
Checking cluster versions                                   ok
Checking database user is the install user                  ok
Checking database connection settings                       ok
Checking for prepared transactions                          ok
Checking for reg* system OID user data types                ok
Checking for contrib/isn with bigint-passing mismatch       ok
Checking for roles starting with 'pg_'                      ok
Creating dump of global objects                             ok
Creating dump of database schemas
                                                            ok
Checking for presence of required libraries                 ok
Checking database user is the install user
database user "dimid" is not the install user

So how come

Checking database user is the install user                  ok
like image 627
dimid Avatar asked Jan 25 '17 14:01

dimid


People also ask

How do I find my postgres user?

Using psql command Enter password to log into PostgreSQL. Enter \du command to list all users in PostrgeSQL. You will see the list of all users and roles. If you want more information such as description for each user, enter \du+ command.

What is user in PostgreSQL?

PostgreSQL roles and users A user is a role with the ability to login (the role has the LOGIN attribute). Because all roles Cloud SQL creates have the LOGIN attribute, Cloud SQL uses the terms "role" and "user" interchangeably.

How do I change the username and password for PostgreSQL?

Log in to psql using the postgres database login role, connecting to the postgres database. Issue the \password command to alter the passwords of the three login roles. The syntax for the \password command is \password <username>. You will be prompted to type a new password.


2 Answers

The old PostgreSQL cluster was obviously created with

initdb -U dimid

but the new cluster was istalled with a different superuser.

You have to create the new cluster with the same superuser name as the old one.

like image 61
Laurenz Albe Avatar answered Sep 16 '22 16:09

Laurenz Albe


Specifically for homebrew postgresql installations, the default user for initdb is $USER -- so if you just followed the instructions initially and did something like

initdb /usr/local/var/postgres -E utf8

the install user is your Unix username. In my case it is 'rob', so just adding '-U rob' to the pg_upgrade works as well:

pg_upgrade -b /usr/local/Cellar/postgresql/9.5.4_1/bin -B /usr/local/Cellar/postgresql/9.6.2/bin -d /usr/local/var/postgres95 -D /usr/local/var/postgres -U rob
like image 45
robm Avatar answered Sep 17 '22 16:09

robm