DoubleLi

qq: 517712484 wx: ldbgliet

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  4737 随笔 :: 2 文章 :: 542 评论 :: 1615万 阅读
< 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

一、简介

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/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

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=# 

测试成功。

更多详情见请继续阅读下一页的精彩内容: http://www.linuxidc.com/Linux/2013-10/92111p2.htm

相关阅读

PostgreSQL删除表中重复数据行 http://www.linuxidc.com/Linux/2013-07/87780.htm

PostgreSQL数据库连接池PgBouncer的搭建 http://www.linuxidc.com/Linux/2013-06/85928.htm

Windows平台编译 PostgreSQL http://www.linuxidc.com/Linux/2013-05/85114.htm

PostgreSQL备份心得笔记 http://www.linuxidc.com/Linux/2013-04/82812.htm

posted on   DoubleLi  阅读(738)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
历史上的今天:
2015-08-11 Linux系统下UDP发送和接收广播消息小例子
2014-08-11 boost 循环缓冲区
2014-08-11 boost::property_tree读取解析.xml文件
2014-08-11 boost::property_tree读取解析ini文件--推荐
2014-08-11 使用ffmpeg向crtmpserver发布rtsp流
2014-08-11 crtmpserver流媒体服务器的介绍与搭建
2014-08-11 boost中asio网络库多线程并发处理实现,以及asio在多线程模型中线程的调度情况和线程安全。
点击右上角即可分享
微信分享提示