Linux下PostgreSQL 的安装与配置
2017-01-11 11:32
323 查看
Linux下PostgreSQL 的安装与配置
原文地址:http://www.linuxidc.com/Linux/2013-10/92111.htm一、简介
PostgreSQL 是一种非常复杂的对象-关系型数据库管理系统(ORDBMS),也是目前功能最强大,特性最丰富和最复杂的自由软件数据库系统。有些特性甚至连商业数据库都不具备。这个起源于伯克利(BSD)的数据库研究计划目前已经衍生成一项国际开发项目,并且有非常广泛的用户。
二、系统环境
系统平台:CentOS release 6.3 (Final)
PostgreSQL 版本:PostgreSQL 9.2.4
防火墙已关闭/iptables: Firewall is not running.
SELINUX=disabled
三、安装方式
A. 下载RPM包安装
B. yum 安装
C. 源码包安装
四、安装过程
A. RPM包安装
1. 检查PostgreSQL 是否已经安装
[root@TS-DEV ~]# rpm -qa|grep postgres [root@TS-DEV ~]#
若已经安装,则使用rpm -e 命令卸载。
2. 下载RPM包
#wget http://yum.postgresql.org/9.2/ href="http://www.linuxidc.com/topicnews.aspx?tid=10" target=_blank>RedHat/rhel-6-i386/postgresql92-server-9.2.4-1PGDG.rhel6.i686.rpm #wget http://yum.postgresql.org/9.2/redhat/rhel-6-i386/postgresql92-contrib-9.2.4-1PGDG.rhel6.i686.rpm #wget http://yum.postgresql.org/9.2/redhat/rhel-6-i386/postgresql92-libs-9.2.4-1PGDG.rhel6.i686.rpm #wget http://yum.postgresql.org/9.2/redhat/rhel-6-i386/postgresql92-9.2.4-1PGDG.rhel6.i686.rpm[/code]
3. 安装PostgreSQL,注意安装顺序# rpm -ivh postgresql92-libs-9.2.4-1PGDG.rhel6.i686.rpm # rpm -ivh postgresql92-9.2.4-1PGDG.rhel6.i686.rpm # rpm -ivh postgresql92-server-9.2.4-1PGDG.rhel6.i686.rpm # rpm -ivh postgresql92-contrib-9.2.4-1PGDG.rhel6.i686.rpm
4. 初始化PostgreSQL库
PostgreSQL 服务初次启动的时候会提示初始化。# service postgresql-9.2 initdb
5. 启动服务# service postgresql-9.2 start
6. 把PostgreSQL 服务加入到启动列表# chkconfig postgresql-9.2 on # chkconfig --list|grep postgres
7. 修改PostgreSQL数据库用户postgres的密码(注意不是linux系统帐号)
PostgreSQL数据库默认会创建一个postgres的数据库用户作为数据库的管理员,默认密码为空,我们需要修改为指定的密码,这里设定为’postgres’。# su - postgres $ psql # ALTER USER postgres WITH PASSWORD 'postgres'; # select * from pg_shadow ;
8. 测试数据库
8.1 创建测试数据库
# create database david;
8.2 切换到david 数据库
# \c david
8.3 创建测试表david=# create table test ( id integer, name text);
8.4 插入测试数据david=# insert into test values (1,'david'); INSERT 0 1 david=#
8.5 选择数据david=# select * from test ; id | name ----+------- 1 | david (1 row) david=#
测试成功。
相关文章推荐
- Linux下apache+phppgadmin+postgresql安装配置
- Postgresql在Linux下的安装配置与C程序应用
- linux---postgresql的安装和配置
- Linux下PostgreSQL 的安装与配置
- linux的数据库篇- PostgreSQL安装配置
- linux下PostgreSQL安装和简单配置
- Linux(Ubuntu)下PostGIS+Postgresql的安装与配置(下)
- 在Linux环境下编译安装配置PostGIS/PostgreSQL全过程
- Linux/UNIX安装PostgreSQL,补充配置要求
- linux postgresql 安装配置详解
- linux下安装配置连接PostgreSQL
- linux 上安装postgresql 并配置pgadmin iii连接
- PostgreSQL 8.4 在Linux(Ubuntu)上的安装 配置
- Linux下PostgreSQL 的安装与配置
- linux 下安装配置postgreSQL
- Linux下PostgreSQL 的安装与配置
- Drupal7 Note-0: Ubuntu 下 LAPP(linux+apache+postgresql+php)环 境的配置与安装
- postgreSQL在linux下的安装配置
- linux下安装postgresql并配置远程图形桌面连接
- postgresql9.5 run 文件linux安装后配置成开机服务