当我尝试运行 psql 时,它说:
psql --version
psql (PostgreSQL) 9.3.12
psql
psql: FATAL: Peer authentication failed for user "testuser"
Run Code Online (Sandbox Code Playgroud)
这是我的pg_hba.conf
:
# Database administrative login by Unix domain socket
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer map=testmap
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
Run Code Online (Sandbox Code Playgroud)
这是我的pg_ident.conf
:
# MAPNAME SYSTEM-USERNAME PG-USERNAME
testmap testuser postgres
Run Code Online (Sandbox Code Playgroud)
并且postgresql.conf
:
data_directory = '/var/lib/postgresql/9.3/main'
hba_file = '/etc/postgresql/9.3/main/pg_hba.conf'
ident_file = '/etc/postgresql/9.3/main/pg_ident.conf'
external_pid_file = '/var/run/postgresql/9.3-main.pid'
listen_addresses = '*'
port = 5432
max_connections = 100
unix_socket_directories = '/var/run/postgresql'
ssl = true
ssl_cert_file = '/etc/ssl/certs/ssl-cert-snakeoil.pem'
ssl_key_file = '/etc/ssl/private/ssl-cert-snakeoil.key'
shared_buffers = 128MB
log_line_prefix = '%t '
log_timezone = 'UTC'
datestyle = 'iso, mdy'
timezone = 'UTC'
lc_messages = 'C'
lc_monetary = 'C'
lc_numeric = 'C'
lc_time = 'C'
default_text_search_config = 'pg_catalog.english'
Run Code Online (Sandbox Code Playgroud)
PostgreSQL 版本:9.3.12
我在做什么错?
此映射的目的是testuser
作为 dbpostgres
用户登录。
在 中pg_hba.conf
,map
关键字应适用于postgres
用户。
同样在 psql 调用中,postgres
作为用户必须明确地作为参数给出。
这对我有用:
pg_hba.conf:
# 通过 Unix 域套接字进行数据库管理登录 本地所有 postgres peer map=testmap # 类型数据库用户地址方法 # "local" 仅用于 Unix 域套接字连接 本地所有所有对等点
调用:
psql -U postgres
Run Code Online (Sandbox Code Playgroud)
确保在修改配置文件后重新加载服务。
归档时间: |
|
查看次数: |
5901 次 |
最近记录: |