1.远程连接失败
[pgsql@oracle1:/postgresql/data]$psql -h 192.168.1.10 -p 5432 -U postgres
2024-08-30 16:48:42.421 CST [55523] FATAL: pg_hba.conf rejects connection for host "192.168.1.7", user "postgres", database "postgres", no encryption
psql: error: connection to server at "192.168.1.10", port 5432 failed: FATAL: pg_hba.conf rejects connection for host "192.168.1.7", user "postgres", database "postgres", no encryption
vi pg_hba.conf
--添加如下,可以允许远程连接。且需要携带密码。
host all all 0.0.0.0/0 scram-sha-256
--重新登陆
[pgsql@oracle1:/postgresql/data]$psql -h 192.168.1.10 -p 5432 -U postgres
Password for user postgres:
psql (15.3)
Type "help" for help.
postgres=#
2.检查版本
postgres=# select version();
version
--------------------------------------------------------------------------------------------------------
-
PostgreSQL 15.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
(1 row)
--检查插件
postgres=# \dx
List of installed extensions
Name | Version | Schema | Description
--------------------+---------+------------+------------------------------------------------------------
------------
pg_stat_statements | 1.10 | public | track planning and execution statistics of all SQL statemen
ts executed
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
(2 rows)
--检查连接信息
postgres=# \conninfo
You are connected to database "postgres" as user "postgres" via socket in "/postgresql/data" at port "5432".
--检查用户
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}

被折叠的 条评论
为什么被折叠?



