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