patternsqlModerate
psql: FATAL: role "postgres" does not exist
Viewed 0 times
postgresfatalexistrolepsqldoesnot
Problem
Running PostgreSQL server on Void Linux. After installing ran
Received output:
creating directory /var/lib/postgresql/data ... ok creating
subdirectories ... ok selecting default max_connections ... 100
selecting default shared_buffers ... 128MB selecting dynamic shared
memory implementation ... posix creating configuration files ... ok
running bootstrap script ... ok performing post-bootstrap
initialization ... locale: Cannot set LC_MESSAGES to default locale:
No such file or directory ok syncing data to disk ... ok
WARNING: enabling "trust" authentication for local connections You can
change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
Success. You can now start the database server using:
pg_ctl -D /var/lib/postgresql/data -l logfile start
I've then proceeded to create the service, grant the ownership to 'postgres' and start it:
Running:
will give me the following error:
I've tried granting ownership of
These were my sources:
https://wiki.voidlinux.eu/PostgreSQL
PostgreSQL error: Fatal: role “username” does not exist
I do not know what to do next.
EDIT: Stumbled upon psql: FATAL: role “postgres” does not exist. Cannot run
initdb as OS user 'postgres':[user@host]$ sudo -u postgres -i
$ initdb -D '/var/lib/postgresql/data'Received output:
creating directory /var/lib/postgresql/data ... ok creating
subdirectories ... ok selecting default max_connections ... 100
selecting default shared_buffers ... 128MB selecting dynamic shared
memory implementation ... posix creating configuration files ... ok
running bootstrap script ... ok performing post-bootstrap
initialization ... locale: Cannot set LC_MESSAGES to default locale:
No such file or directory ok syncing data to disk ... ok
WARNING: enabling "trust" authentication for local connections You can
change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
Success. You can now start the database server using:
pg_ctl -D /var/lib/postgresql/data -l logfile start
I've then proceeded to create the service, grant the ownership to 'postgres' and start it:
[user@host]$ ln -s /etc/sv/postgresql /var/service
[user@host]$ sudo chown postgres: /var/service/postgresql
[user@host]$ sudo sv start postgresql
[user@host]$ ls -l /var/service/postgresql
lrwxrwxrwx 1 postgres postgres 18 nov 2 17:05 /var/service/postgresql -> /etc/sv/postgresqlRunning:
[user@host]$ sudo -u postgres psql ...will give me the following error:
psql: FATAL: role "postgres" does not existI've tried granting ownership of
/etc/sv/postgresql to 'postgres', but no luck.These were my sources:
https://wiki.voidlinux.eu/PostgreSQL
PostgreSQL error: Fatal: role “username” does not exist
I do not know what to do next.
EDIT: Stumbled upon psql: FATAL: role “postgres” does not exist. Cannot run
psql -l because I get the same error, no matter which user I run psql as.Solution
Not a full answer, but consider the manual about
Selects the user name of the database superuser. This defaults to the
name of the effective user running
what the superuser's name is, but one might choose to keep the
customary name postgres, even if the operating system user's name is different.
Meaning ...
-
When running
-
You should be able to force the name
initdb here:-Uusername--username=usernameSelects the user name of the database superuser. This defaults to the
name of the effective user running
initdb. It is really not importantwhat the superuser's name is, but one might choose to keep the
customary name postgres, even if the operating system user's name is different.
Meaning ...
-
When running
initdb as OS user postgres, the initial DB superuser role is postgres as well - in standard Postgres. I have heard of systems bending this rule ...-
You should be able to force the name
postgres with --username=postgres for the initial superuser - unless your package seriously messed with all this.Context
StackExchange Database Administrators Q#221663, answer score: 12
Revisions (0)
No revisions yet.