postgreSQL离线安装(rpm包方式)

1、下载pg的rpm包,https://yum.postgresql.org,根据选择适合的版本,这里以centos7和pg13.0为例,下载好这四个rpm包:

postgresql13-server-13.0-1PGDG.rhel7.x86_64.rpm
postgresql13-13.0-1PGDG.rhel7.x86_64.rpm
postgresql13-contrib-13.0-1PGDG.rhel7.x86_64.rpm
postgresql13-libs-13.0-1PGDG.rhel7.x86_64.rpm

 2、上传到服务器后,执行:rpm -ivh *.rpm,记录两个经常缺的依赖下载地址:

http://mirror.centos.org/centos/7/os/x86_64/Packages/libicu-50.2-4.el7_7.x86_64.rpm
http://mirror.centos.org/centos/7/os/x86_64/Packages/libxslt-1.1.28-6.el7.x86_64.rpm

3、创建data目录,比如放在/home/pg13下:mkdir /home/pg13

4、给目录授权:

chown -R postgres:postgres /home/pg13

chmod -R 700 /home/pg13

5、切换用户:su postgres  ,切换到主目录:cd

6、配置环境变量(不嫌以后操作麻烦可跳过此步骤),

在.bash_profile文件中,加入以下几行后,执行source .bash_profile

PGDATA=/home/pg13
export PGDATA
PGHOME=/usr/pgsql-13
PATH=$PGHOME/bin:$PATH
export PATH

7、初始化数据库:initdb -d /home/pg13

8、配置允许远程访问:

(1)/home/pg13/postgresql.conf中,取消 listen_addresses 的注释,将参数值改为“*”

(2)/home/pg13/pg_hba.conf中,添加一行:host    all             all             0.0.0.0/0               md5

9、设置数据库密码,执行psql进到postgres数据库,执行:alter user postgres with password '*';

10、数据库启停(需要使用postgres用户操作),如果有第6步的环境变量配置,使用括号内的命令即可:

/usr/pgsql-13/bin/pg_ctl -D /home/pg13 start           (pg_ctl start)
/usr/pgsql-13/bin/pg_ctl -D /home/pg13 stop           (pg_ctl stop)
/usr/pgsql-13/bin/pg_ctl -D /home/pg13 restart        (pg_ctl restart)

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
THE END
分享
二维码
< <上一篇
下一篇>>