CentOS7 安裝postpreSql 12+ 最新版本

 

  1. Install the repository RPM:
    yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
  2. Install the client packages:
    yum install postgresql12
  3. Optionally install the server packages:
    yum install postgresql12-server
  4. Optionally initialize the database and enable automatic start:
    /usr/pgsql-12/bin/postgresql-12-setup initdb
    systemctl enable postgresql-12
    systemctl start postgresql-12

    5.修改密碼 

su - postgres
psql

效果:

 輸入修改密碼的命令:

 

ALTER USER postgres WITH PASSWORD '123456';
退出

退出:\q

備註其他:列出所有庫\l  列出所有用戶\du 列出庫下所有表\d

6、默認情況下postgresql是不用密碼不支持遠程登錄的。我們需要修改配置文件

修改配置

vi /var/lib/pgsql/12/data/pg_hba.conf

修改後:

保存退出

我們改遠程訪問

vi /var/lib/pgsql/12/data/postgresql.conf

修改後的

保存退出重啓

systemctl restart postgresql-12

關閉防火牆

systemctl stop firewalld.service 

查看防火牆狀態

systemctl status firewalld.service
 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章