linux下安装postgresql12并配置远程访问

1、centos7下安装postgresql
# Install the repository RPM: yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm # Install PostgreSQL: yum install -y postgresql12-server # Optionally initialize the database and enable automatic start: /usr/pgsql-12/bin/postgresql-12-setup initdb systemctl enable postgresql-12 systemctl start postgresql-12

2、#进入/var/lib/pgsql/12/data

   a、修改postgresql.conf 取消#listen_addresses = 'localhost'注释 修改为listen_addresses = '*'

   b、修改pg_hba.conf

   # IPv4 local connections: host all all 127.0.0.1/32 trust

 

   host all all 0.0.0.0/0 md5 #允许外网访问,,密码md5加密

3、重启postgresql服务

4、修改postgersql密码

su postgres
bash-4.2$ psql -U postgres -W
口令:
psql (12.4)
输入 "help" 来获取帮助信息.

postgres=# alert user postgres with password 'topwalk';

5、防火墙打开端口,以CentOS7为例
sudo firewall-cmd --permanent --zone=public --add-port=5432/tcp
sudo firewall-cmd --reload
posted @ 2020-10-14 17:55  不懂8  阅读(1161)  评论(0编辑  收藏  举报