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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM