postgresql - 更改为 pg_hba.conf 和 postgresql.conf 以使用 pgadmin 与所有用户连接后无法启动 postgres 服务器
问题描述
这是我在 ubantu 机器上安装 postgresql 时遇到的错误。然后在那台机器上我可以成功连接它但是一旦我更改为下面的文件以允许所有用户连接它。然后我注意到它不会启动
psql:无法连接到服务器:没有这样的文件或目录服务器是否在本地运行并接受 Unix 域套接字“/var/run/postgresql/.s.PGSQL.5432”上的连接?
BELOW you can see my 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
# IPv4 local connections:
host all all 0.0.0.0/0 md5
ghost 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 all peer
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
-------------------------------------------------------------------------
下面你可以看到 postgresql.conf
# The default values of these variables are driven from the -D command-line
# option or PGDATA environment variable, represented here as ConfigDir.
data_directory = '/var/lib/postgresql/10/main' # use data in another directory
# (change requires restart)
hba_file = '/etc/postgresql/10/main/pg_hba.conf' # host-based authentication file
# (change requires restart)
ident_file = '/etc/postgresql/10/main/pg_ident.conf' # ident configuration file
# (change requires restart)
# If external_pid_file is not explicitly set, no extra PID file is written.
external_pid_file = '/var/run/postgresql/10-main.pid' # write an extra PID file
# (change requires restart)
#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------
# - Connection Settings -
listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5432 # (change requires restart)
max_connections = 100 # (change requires restart)
#superuser_reserved_connections = 3 # (change requires restart)
unix_socket_directories = '/var/run/postgresql' # comma-separated list of directories
# (change requires restart)
#unix_socket_group = '' # (change requires restart)
#unix_socket_permissions = 0777 # begin with 0 to use octal notation
# (change requires restart)
#bonjour = off # advertise server via Bonjour
# (change requires restart)
#bonjour_name = '' # defaults to the computer name
# (change requires restart)
# - Security and Authenticatio
n-`
解决方案
推荐阅读
- android - gradlew assembleRelease 不适用于 react-native-camera
- java - 是否可以在以 adb 启动的 Java 服务中创建活动?
- ssh - Windows 10 上的错误“getsockname failed: Not a socket”
- github - 如何接受 GitHub 上的私有存储库所有权?
- webrtc - 转服务器中继端口在严格的防火墙中被阻止
- django - 验证电子邮件地址确实存在
- csv - Apache Superset - CSV 上传问题:FileNotFoundError
- c - 预处理器会扩展用引号括起来的宏吗?
- python - 我想在数据库 python-flask 中更新,我编写了用于编辑的代码,但我没有收到任何错误,但值在更改后仍然保持以前的值
- spring - 如何从 spring application.yml 读取属性并在我的 log4j2.xml 中使用它