20.15. Проблемы аутентификации
Сбои и другие проблемы с аутентификацией обычно дают о себе знать через сообщения об ошибках, например:
FATAL: no pg_hba.conf entry for host "123.123.123.123", user "andym", database "testdb"
Это сообщение вы, скорее всего, получите, если сможете связаться с сервером, но он не захочет с вами общаться. В сообщении содержится предположение, что сервер отказывает вам в подключении, поскольку не может найти подходящую запись в файле pg_hba.conf.
FATAL: password authentication failed for user "andym"
Такое сообщение показывает, что вы связались с сервером, он готов общаться с вами, но только после того, как вы прошли авторизацию по методу, указанному в файле pg_hba.conf. Проверьте пароль, который вы вводите, и как настроен Kerberos или ident, если в сообщении упоминается один из этих типов аутентификации.
FATAL: user "andym" does not exist
Указанное имя пользователя базы данных не найдено.
FATAL: database "testdb" does not exist
База данных, к которой вы пытаетесь подключиться, не существует. Имейте в виду, что если вы не указали имя базы данных, по умолчанию берётся имя пользователя базы данных, что может приводить к ошибкам.
Подсказка
В журнале сервера может содержаться больше информации, чем в выдаваемых клиенту сообщениях об ошибке аутентификации, поэтому, если вас интересуют причины сбоя, проверьте журнал сервера.
20.15. Authentication Problems
Authentication failures and related problems generally manifest themselves through error messages like the following:
FATAL: no pg_hba.conf entry for host "123.123.123.123", user "andym", database "testdb"
This is what you are most likely to get if you succeed in contacting the server, but it does not want to talk to you. As the message suggests, the server refused the connection request because it found no matching entry in its pg_hba.conf configuration file.
FATAL: password authentication failed for user "andym"
Messages like this indicate that you contacted the server, and it is willing to talk to you, but not until you pass the authorization method specified in the pg_hba.conf file. Check the password you are providing, or check your Kerberos or ident software if the complaint mentions one of those authentication types.
FATAL: user "andym" does not exist
The indicated database user name was not found.
FATAL: database "testdb" does not exist
The database you are trying to connect to does not exist. Note that if you do not specify a database name, it defaults to the database user name, which might or might not be the right thing.
Tip
The server log might contain more information about an authentication failure than is reported to the client. If you are confused about the reason for a failure, check the server log.