При подключении к postgres из командной строки не забудьте добавить -h localhost
в качестве параметра командной строки. Если нет, postgres попытается подключиться с использованием режима аутентификации PEER.
Ниже показано сброс пароля, сбой входа в систему с аутентификацией PEER и успешный вход в систему с использованием TCP-соединения.
# sudo -u postgres psql
could not change directory to "/root"
psql (9.1.11)
Type "help" for help.
postgres=# \password
Enter new password:
Enter it again:
postgres=# \q
Неудача:
# psql -U postgres -W
Password for user postgres:
psql: FATAL: Peer authentication failed for user "postgres"
Работа с -h localhost
:
# psql -U postgres -W -h localhost
Password for user postgres:
psql (9.1.11)
SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
Type "help" for help.
postgres=#