1.安装postgresql
# 安装依赖包
yum install -y glibc-devel bison flex readline-devel zlib-devel pgdg-srpm-macros lz4-devel libicu-devel llvm5.0-devel llvm-toolset-7-clang krb5-devel e2fsprogs-devel \
openldap-devel pam-devel perl-ExtUtils-Embed python3-devel tcl-devel systemtap-sdt-devel libselinux-devel openssl-devel libuuid-devel libxml2-devel libxslt-devel systemd-devel \
gcc gcc-c++
# libedit-devel
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/libedit-devel-3.0-12.20121213cvs.el7.x86_64.rpm
rpm -ivh libedit-devel-3.0-12.20121213cvs.el7.x86_64.rpm
# llvm5.0-devel
wget https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-14.noarch.rpm
rpm -ivh epel-release-7-14.noarch.rpm
yum install -y llvm5.0-devel
# lz4-devel
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/lz4-devel-1.8.3-1.el7.x86_64.rpm
rpm -ivh lz4-devel-1.8.3-1.el7.x86_64.rpm
# llvm-toolset-7-clang
#写入yum源
cat << EOF > /etc/yum.repos.d/c7-devtoolset-7-x86_64.repo
[c7-devtoolset-7]
name=c7-devtoolset-7
baseurl=https://buildlogs.centos.org/c7-devtoolset-7.x86_64/
gpgcheck=0
enabled=1
[c7-llvm-toolset-7]
name=c7-llvm-toolset-7
baseurl=https://buildlogs.centos.org/c7-llvm-toolset-7.x86_64/
gpgcheck=0
enabled=1
[fedoraproject-epel-7]
name=fedoraproject-epel-7
baseurl=https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/
gpgcheck=0
enabled=1
EOF
yum install -y llvm5.0-devel llvm-toolset-7-clang
# 下载官方RPM:
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# 安装PostgreSQL:
sudo yum install -y postgresql14-libs postgresql14 postgresql14-devel postgresql14-contrib.x86_64
# 初始化数据:
sudo /usr/pgsql-14/bin/postgresql-14-setup initdb
如果出现Data directory is not empty!,
cd /var/lib/pgsql/14/
rm -rf data
再次执行初始化命令 sudo /usr/pgsql-14/bin/postgresql-14-setup initdb
# 设置开机自启动并启动PostgreSQL:
sudo systemctl enable postgresql-14
sudo systemctl start postgresql-14
2.配置postgresql
切换到postgres用户
su - postgres
-bash-4.2$ psql
用户 postgres 的口令:
psql (14.2)
输入 "help" 来获取帮助信息.
修改系统用户密码,一定要修改不然等你改完配置文件就不能这么轻松愉快的进入这个页面了
postgres=# ALTER USER postgres WITH PASSWORD 'postgres';
postgres=# \q
修改配置文件
vim /var/lib/pgsql/14/data/postgresql.conf
开启远程访问,将listen_address 修改为 * ,端口号可改可不改
vim /var/lib/pgsql/14/data/pg_hba.conf
在文件末尾增加如下配置
host all all 0.0.0.0/0 scram-sha-256
3.重启服务,远程链接测试
sudo systemctl restart postgresql-14
[root@jerry ~]# psql -U postgres -h 127.0.0.1 --port 58063
用户 postgres 的口令:
psql (14.2)
输入 "help" 来获取帮助信息.
postgres=#
4.postgresql数据库备份恢复
备份命令:pg_dump -U postgres -d template_postgis -f template_postgis.sql
恢复命令:psql -U postgres -d aaa -f template_postgis.sql
标签:postgresql,x86,postgis,devel,centos7,64,14,yum,postgres
From: https://www.cnblogs.com/chunjeh/p/17932846.html