Home > Blockchain >  why POSTGRES database uses postgres user as superuser/default user ? how to change it?
why POSTGRES database uses postgres user as superuser/default user ? how to change it?

Time:10-01

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

CodePudding user response:

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

CodePudding user response:

thank you Laurenz,

as per your suggestion i tried to start psql database with below command and posting error message as well.

enter image description here

  • Related