2

we are planning to install postgresql-13 on our production cluster. but as we have postgres as default user , i want to remove it and use superuser of prod cluster. can any on suggest how to install psql-13 with prod superuser as a default user ?

prod superuser should own all file and folder which will be generated while installing.

Thanks in Advance

rishikanth
  • 21
  • 1
  • 1
    You can define the name of the superuser when running [initdb](https://www.postgresql.org/docs/current/app-initdb.html). But what do you mean with "superuser of prod cluster"? –  Sep 29 '22 at 14:34
  • Use -U username or --username=username when running initdb – Frank Heikens Sep 29 '22 at 15:06

1 Answers1

0

You can choose the bootstrap user name when you create the cluster:

initdb -U fuzzy -E UTF8 --locale=en_US.utf8 /path/to/data/directory

But you can also rename the user any time later:

psql -U postgres
postgres=# CREATE ROLE x LOGIN SUPERUSER;
CREATE ROLE
postgres=# \connect - x
You are now connected to database "postgres" as user "x".
postgres=# ALTER ROLE postgres RENAME TO fuzzy;
ALTER ROLE
postgres=# \connect - fuzzy
You are now connected to database "postgres" as user "fuzzy".
postgres=# DROP ROLE x;
DROP ROLE
postgres=# \quit
Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263