Unable to connect to PostgreSQL server: FATAL: Peer authentication failed for user "postgres"
Wie kann, wie Sie Zugang zu postgres-Datenbanken von adminer?
Habe ich das Passwort geändert für den Anwender postgres
:
$ sudo -u postgres psql
$ postgres=# alter user postgres password 'secret';
Ergebnis:
ALTER ROLE
Aber ich bekomme immer noch diese Fehler auf den adminer:
Unable to connect to PostgreSQL server: FATAL: Peer authentication failed for user "postgres"
Irgendwelche Ideen, warum?
Habe ich diese zwei Benutzer:
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
root | Superuser, Create role, Create DB | {}
Aber habe ich nicht gesetzt-Kennwort für Benutzer root
wenn ich es mit diesem Befehl:
sudo -u postgres createuser --interactive
Ausgang (warum nicht Fragen, für Passwort??):
Enter name of role to add: root
Shall the new role be a superuser? (y/n) y
Aber ich bekomme immer noch den Fehler auf adminer:
Unable to connect to PostgreSQL server: FATAL: Peer authentication failed for user "root"
EDIT:
Dies ist einige bits von meinem pg_hba.conf
sudo nano /etc/postgresql/9.5/main/pg_hba.conf
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5
Änderte ich peer
zu ident
:
# Database administrative login by Unix domain socket
local all postgres ident
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all ident
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5
Dann neu gestartet, meine Maschine. aber immer noch kein Glück.
Du musst angemeldet sein, um einen Kommentar abzugeben.
Habe meine Antwort von hier:
und dann den Dienst neu starten:
Sieht aus wie du bist "peer-Authentifizierung", wo Sie sich mit "Kennwort-Authentifizierung". Mit der Standard-pg_hba.conf können Sie wechseln, um die Passwort-Authentifizierung durch Angabe eines Hostnamens oder "127.0.0.1".
Sehen die Postgres-Dokumentation für Authentifizierungsmethoden.