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== > 来自 <[https://www.postgresql.org/download/linux/redhat/](https://www.postgresql.org/download/linux/redhat/)> [Service] Type=notify User=postgres Group=postgres # Note: avoid inserting whitespace in these Environment= lines, or you may # break postgresql-setup. # Location of database directory Environment=PGDATA=/var/lib/pgsql/12/data/ 初始化之后,数据文件会存在 /var/lib/pgsql/12/data > 来自 <[https://www.postgresql.org/download/linux/redhat/](https://www.postgresql.org/download/linux/redhat/)>