已有postgres9.6的linux服务器安装postgresql13过程记录

239 阅读1分钟

官网上给出的安装命令如下

# Install the repository RPM: sudo yum install -y download.postgresql.org/pub/repos/y…
# Install PostgreSQL:
sudo yum install -y postgresql13-server
# 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

那么开始安装,首先按照官网提示更新yum源

sudo yum install -y download.postgresql.org/pub/repos/y…

安装数据库
sudo yum install -y postgresql13-server  

安装完毕后切换到postgres用户,初始化数据库并指定数据库存储路径 /usr/pgsql-13/bin/initdb -D /var/lib/pgsql/13/data/

修改配置文件中端口为5434,修改配置文件开启远程访问数据库许可,之后启动数据库

退出postgres用户,使用systemctl start postgresql-13启动

修改用户密码
psql
ALTER USER postgres WITH PASSWORD 'postgres';

安装POSTGIS扩展
yum install postgis31_13.x86_64 -y

连接需要安装扩展的数据库,安装扩展

CREATE EXTENSION postgis;