增加 Yum 源
拜访 https://www.postgresql.org/download 抉择操作 postgresql 版本及对应的操作系统,从生成装置脚本中抉择 rpm 源。
执行装置命令
# Install the repository RPM:
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# Install PostgreSQL:
sudo yum install postgresql13-server -y
# Optionally initialize the database and enable automatic start:
sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
sudo systemctl enable postgresql-13
sudo systemctl start postgresql-13
设置环境变量
vim ~/.bashrc
export PATH=$PATH:/usr/pgsql-13/bin
登录
$ su postgres
$ psql