我最先安装的是windows PostgreSQL 15版本的,然后本机的navicate版本也是15,用navicat链接的时候,提示字段 "datlastsysoid" 不存在 ,网上说navicat16修复了这个问题,但我并没有试,想着试试安装linux版本试试,于是装了linux版本的postgres 。
1. 在postgresql网站选择对应版本, 选择需要安装的版本,linux的版本信息。
postgresql网站: https://www.postgresql.org/download/
2.获取安装脚本命令,在linux命令窗口依次执行。
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm sudo yum install -y postgresql14-server sudo /usr/pgsql-14/bin/postgresql-14-setup initdb sudo systemctl enable postgresql-14 sudo systemctl start postgresql-14
注意:以上都完成后,虽然安装好了postgresql数据库,但远程还不同,需要设置远程访问。
3.远程访问数据库设置
需设置两个配置文件
1)修改配置文件postgresql.conf,
vim /var/lib/pgsql/14/data/postgresql.conf
修改监听地址:
#listen_addresses=’localhost’ #port = 5432 listen_addresses=’*’ port = 5432
2)修改配置文件/pgsql/data/pg_hba.conf:
vim /var/lib/pgsql/14/data/pg_hba.conf
设置所有网段IP可以访问
# 这是在 /var/lib/pgsql/14/data/pg_hba.conf文件里加 # IPv4 myhost connections: host all all 0.0.0.0/0 trust
文档里的#代表注释
4.官网命令执行,默认的数据库
默认创建好的数据库:postgres
用户名:postgres
密码:123456
官网命令执行后了,是设置开机自启动的。
关闭防火墙
systemctl status firewalld.service systemctl stop firewalld.service systemctl disable firewalld.service