Red Hat Enterprise Linux
CentOS
Fedora
Scientific Linux
Oracle Linux
yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
rpm -qa | grep postgres
rpm -e postgresqlXX
yum install postgresql12
yum install postgresql12-server
/usr/pgsql-12/bin/postgresql-12-setup initdb
systemctl enable postgresql-12
systemctl start postgresql-12
[root@centos7 ~]# ps -ef | grep postgres | grep -v 'grep'
postgres 29118 1 0 16:57 ? 00:00:00 /usr/pgsql-12/bin/postmaster -D /var/lib/pgsql/12/data/
postgres 29120 29118 0 16:57 ? 00:00:00 postgres: logger
postgres 29122 29118 0 16:57 ? 00:00:00 postgres: checkpointer
postgres 29123 29118 0 16:57 ? 00:00:00 postgres: background writer
postgres 29124 29118 0 16:57 ? 00:00:00 postgres: walwriter
postgres 29125 29118 0 16:57 ? 00:00:00 postgres: autovacuum launcher
postgres 29126 29118 0 16:57 ? 00:00:00 postgres: stats collector
postgres 29127 29118 0 16:57 ? 00:00:00 postgres: logical replication launcher
yum install postgresql12-contrib
yum pgadmin4
[root@centos7 ~]# su - postgres
Last login: Sun May 17 10:30:23 CST 2020 on pts/1
-bash-4.2$ psql
psql (12.3)
Type "help" for help.
postgres=# select version();
version
---------------------------------------------------------------------------------------------------------
PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39), 64-bit
(1 row)
修改 postgresql.conf 文件中的监听地址,该文件位于数据目录(/var/lib/pgsql/12/data/)中。找到以下内容:
#listen_addresses = 'localhost' # what IP address(es) to listen on;
将 ‘localhost’ 修改为服务器的 IP 地址或者 ‘*’:
listen_addresses = '192.68.56.103'
修改 pg_hba.conf 文件中的客户端认证配置,该文件位于数据目录(/var/lib/pgsql/12/data/)中。增加以下内容,允许所有客户端 IP 访问:
host all all 0.0.0.0/0 md5
重启服务即可(使用 root 用户操作):
systemctl restart postgresql-12
原文作者:SQL编程思想;如有侵权,请联系管理员删除。