This happens when you run initdb
with a user whose ID is not postgres
, without specifying the postgres
username with --username=postgres
or -U postgres
.
The database cluster is then created with the system's user account that you used to run initdb, and it is given superuser permissions.
To fix it, simply create a new user named postgres
with the option --superuser
using the createuser
utility that comes with Postgres. The utility can be found in the Postgres' bin
directory. e.g.
createuser --superuser postgres
If you have a custom hostname or port then be sure to set the appropriate options.
Don't forget to delete the other user account that was created for you by initdb.