随笔 - 272  文章 - 0  评论 - 283  阅读 - 142万

离线安装PostgreSQL

操作系统 :CentOS5.8_x64

PostgreSQL版本 :9.1

问题描述

服务器未连接公网时怎么安装PostgreSQL数据库?

服务器版本为: CentOS5.8_x64

需要安装的PostgreSQL版本为:9.1

解决方案

解决yum源的问题【可选】

wget http://archives.fedoraproject.org/pub/archive/epel/5/x86_64/epel-rpm-macros-5-7.noarch.rpm
rpm -ivh epel-rpm-macros-5-7.noarch.rpm
yum clean all && yum clean metadata && yum clean dbcache && yum makecache

添加PostgreSQL源并下载PostgreSQL

wget https://download.postgresql.org/pub/repos/yum/9.1/redhat/rhel-5Server-x86_64/pgdg-centos91-9.1-6.noarch.rpm --no-check-certificate
rpm -ivh pgdg-centos91-9.1-6.noarch.rpm
yum search postgres
mkdir psql91
yum install --downloadonly --downloaddir=psql91 postgresql91 postgresql91-server
tar zcvf psql91.tar.gz psql91

--downloadonly参数需要安装yum-downloadonly,命令如下:

yum install yum-downloadonly

如果上述安装命令无法安装的话,可以从CentOS5.8的DVD安装盘里面把rpm包copy出来即可,然后执行安装命令:

rpm -ivh yum-downloadonly-1.1.16-21.el5.centos.noarch.rpm

离线安装PostgreSQL

将psql91.tar.gz文件copy到需要安装的机器上,执行以下命令:

tar zxvf psql91.tar.gz
cd psql91
rpm -ivh postgresql91-libs-9.1.24-2PGDG.rhel5.x86_64.rpm
rpm -ivh postgresql91-9.1.24-2PGDG.rhel5.x86_64.rpm
rpm -ivh postgresql91-server-9.1.24-2PGDG.rhel5.x86_64.rpm

其它

初始化数据库:

service postgresql-9.1 initdb

配置开机启动:

chkconfig postgresql-9.1 on

启动服务:

service postgresql-9.1 start

创建用户示例代码:

su - postgres
psql
CREATE USER uadmin WITH PASSWORD '123456';
CREATE DATABASE testdb OWNER uadmin;
GRANT ALL PRIVILEGES ON DATABASE testdb to uadmin;

好,就这些了,希望对你有帮助。

本文github地址:

https://github.com/mike-zhang/mikeBlogEssays/blob/master/2017/20171018_离线安装PostgreSQL.rst

欢迎补充

posted on   Mike_Zhang  阅读(2604)  评论(0编辑  收藏  举报
(评论功能已被禁用)
编辑推荐:
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示