https://zh.wikipedia.org/wiki/PostgreSQL

PostgreSQL自由的对象-关系型数据库服务器(数据库管理系统),在灵活的BSD-风格许可证下发行。它在其他开放源代码数据库系统(比如MySQLFirebird),和专有系统比如OracleSybase、IBM的DB2Microsoft SQL Server之外,为用户又提供了一种选择。

PostgreSQL不寻常的名字导致一些读者停下来尝试拼读它,特别是那些把SQL拼读为"sequel"的人。PostgreSQL开发者把它拼读为"post-gress-Q-L"。(Audio sample,5.6k MP3)。它也经常被简略念为"postgres"。

在PostgreSQL中程序员可以用一组可观的支持语言中任何一种来写这种逻辑。

  • 类似于Oracle的过程语言PL/SQL的叫做PL/PgSQL的内置语言,在处理查询密集的过程时提供了独特的优势。
  • 流行脚本语言比如PerlPythonTcl,和Ruby的包装器,允许利用它们在字符串处理和连接到广阔的外部函数库的力量。
  • 需要把复杂逻辑编译到机器代码所能提供的高性能的过程可以利用CC++
  • 在更加深奥的方面,R统计语言的处理器允许数据库查询利用它的一组丰富的统计函数。

程序员可以把代码作为函数插入服务器中,它是使代码类似于存储过程的一个小包装器。以这种方式SQL代码可以调用(比如)C代码或反之。

  • 性能增进,因为数据库引擎在一个时间一个地方调用所有的逻辑,减少了在客户和服务器之间的来回往返的次数。
  • 可靠性增进,因为数据验证代码集中到一个地方,就在服务器上,而不用依赖在多个客户应用中的同步逻辑,它们甚至可能以多种编程语言写成。
  • 通过向服务器增加有用的抽象,客户代码可以变得更短小和简单。

这些优势合起来可以证实PostgreSQL从编程角度是最高级的数据库系统。使用PostgreSQL可以显著的减少很多项目的整体编程时间,这种优势随着项目复杂而增长。

通过函数,可以在数据库服务器端执行指令程序。尽管这样的指令程序可以使用基本的SQL语句写成,但是由于其缺乏流程控制等功能,所以在PostgreSQL中引入了使用其它程序语言编写函数的能力,包括:

以上部分的语言,甚至可以在触发器内执行。PostgreSQL支持行返回函数:它们的输出是一系列行类型数据的集合,可以在查询中当作表来使用。函数也可以被定义成以创建者或者调用者的身份运行。在某些场合,或者其他的数据库产品中,函数也会被称为“存储过程”,但技术上这两者并未有太大分别。

吸引我注意的是上面所说的,有强大的编程能力。以前一直用 T-SQL写SP,觉得它的表达能力非常有限,正想寻找一个有强大的编程能力的数据库引擎。

官网:

https://www.postgresql.org/

https://www.postgresql.org/download/linux/redhat/

简单的安装命令,但版本不是最新的:

yum install postgresql-server

若想安装最新版本,需要添加repo.

https://yum.postgresql.org/repopackages.php

Please note that PostgreSQL YUM repository depends on EPEL repository for some packages. RHEL/CentOS/, etc.

users should install EPEL repo RPM along with PGDG repo RPMs to satisfy dependencies.

1: EPEL (Extra Packages for Enterprise Linux)

https://support.rackspace.com/how-to/install-epel-and-additional-repositories-on-centos-and-red-hat/

  • CentOS and Red Hat Enterprise Linux 6.x

    wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
    sudo rpm -Uvh epel-release-6*.rpm
  • CentOS and Red Hat Enterprise Linux 7.x

    wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    sudo rpm -Uvh epel-release-latest-7*.rpm

2: PGDG repo

http://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6-x86_64/pgdg-centos96-9.6-3.noarch.rpm

成功安装后会发现:

/etc/yum.repos.d

目录出了几个文件:

-rw-r--r--. 1 root root  957 12月 10 15:32 epel.repo

-rw-r--r--. 1 root root 1056 12月 10 15:32 epel-testing.repo

-rw-r--r--. 1 root root 1364 12月 10 15:57 pgdg-96-centos.repo

-rw-r--r--. 1 root root 1012 12月 10 15:45 pgdg-96-centos.repo.backup

输入命令:

# yum info postgresql96-server

若出现路径错误, 需要分别修改一下路径:

http://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6.2-x86_64/

最后成功提示包信息,说明配置成功。

最后执行:

[root@localhost yum.repos.d]# yum groupinstall "PostgreSQL Database Server 9.6 PGDG"

...

已安装:

postgresql96.x86_64 0:9.6.1-1PGDG.rhel6

postgresql96-contrib.x86_64 0:9.6.1-1PGDG.rhel6

postgresql96-libs.x86_64 0:9.6.1-1PGDG.rhel6

postgresql96-server.x86_64 0:9.6.1-1PGDG.rhel6

完毕!

说明安装成功。


安装pl/python扩展语言

/usr/pgsql-9.6/bin/
/var/lib/pgsql/9.6/data/

yum install postgresql96-plpython        plpython扩展语言
安装好包之后在postgres命令行中创建语言:
create language plpythonu;

yum install postgresql96-plperl        plpython扩展语言

create language plperl;

create language plperlu;

yum search postgresql

安装PL/Proxy
yum install plproxy96


启动服务:

service postgresql-9.6 initdb
service postgresql-9.6 start
设置开机启动 :
chkconfig postgresql-9.6 on
chkconfig --list | grep postgresql

参考: http://www.cnblogs.com/mchina/archive/2012/06/06/2539003.html

改配置: /var/lib/pgsql/9.6/data/postgresql.conf

 listen_addresses = '*'

连接数据库:

psql -U postgres -h localhost postgres

psql -U 用户名 -h 主机IP 数据库名

若提示: psql: FATAL:  Ident authentication failed for user "postgres"

将/var/lib/pgsql/9.6/data/pg_hba.conf 中 最后 ident改为md5, 如下:

79 # "local" is for Unix domain socket connections only
 80 local   all             all                                     ident
 81 # IPv4 local connections:
 82 host    all             all             127.0.0.1/32            md5
 83 host    all             all             192.168.1.1/24          md5
 84 # IPv6 local connections:
 85 host    all             all             ::1/128                 ident

重启 service postgresql-9.6 restart


CentOS 7:

# cd /usr/pgsql-9.6/bin

# ./postgresql96-setup initdb
Initializing database ... OK

# su - postgres

-bash-4.2$ psql

postgres=# alter user postgres with password 'postgres';

# psql -h localhost -U postgres

CentOS 6安装PostgreSQL的更多相关文章

  1. Linux CentOS 7 安装PostgreSQL 9.5.17 (源码编译)

    近日需要将PostgreSQL数据库从Windows中迁移到Linux中,Linux CentOS 7 安装PostgreSQL 9.5.17 安装过程 特此记录. 安装环境: 数据库:Postgre ...

  2. CentOS 7 - 安装PostgreSQL

    一,用yum安装PostgreSQL . 选择安装版本和服务器平台后,执行安装命令,例如我要安装是9.6版本,平台是CentOS 7. https://www.postgresql.org/downl ...

  3. CentOS下安装postgresql

    一.说明 postgresql版本:9.4.1 安装包: postgresql94-server-9.4.1-1PGDG.rhel6.x86_64.rpm postgresql94-libs-9.4. ...

  4. 阿里云服务器 centos 7 安装postgresql 11

    Postgresql简介 官方网站:https://www.postgresql.org/ 简介参考zhihu文章 https://www.zhihu.com/question/20010554 关于 ...

  5. Centos 7 安装 PostgreSQL

    本文只讲PostgreSQL在CentOS 7.x 下的安装,其他系统请查看:https://www.postgresql.org/download PostgreSQL 所用版本为:PostgreS ...

  6. Centos 7 安装 PostgreSQL PGAdmin4

    本文只讲PostgreSQL在CentOS 7.x 下的安装,其他系统请查看:https://www.postgresql.org/download PostgreSQL 所用版本为:PostgreS ...

  7. centos 7安装postgresql10.3

    最新版本安装请移步:阿里云服务器 centos 7 安装postgresql 11 一.Postgresql简介 官方网站:https://www.postgresql.org/ 简介参考zhihu文 ...

  8. Linux 安装 PostgreSQL

    Linux 安装 PostgreSQL CentOS 7 安装 PostgreSQL 10 步骤 官网安装步骤,选择服务器和数据库版本,会给出相应的安装命令 # 安装 yum install -y h ...

  9. Linux CentOS安装postgresql 9.4

    一.前言 PostgreSQL通常也简称Postgres,是一个关系型数据库管理系统,适用于各种Linux操作系统.Windows.Solaris.BSD和Mac OS X.PostgreSQL遵循P ...

随机推荐

  1. 程序中使用ajax时,type为put,或者delete时在 IIS上没效果,发生HTTP Error 405.0 - Method Not Allowed

    其实使用put delete  是在创建webapi中基本才会使用. WebDAV 是超文本传输协议 (HTTP) 的一组扩展,为 Internet 上计算机之间的编辑和文件管理提供了标准.利用这个协 ...

  2. python_配置

    代码示例:https://pan.baidu.com/s/1pLjLPSv 1.自动补全功能 许多人都知道 iPython 有很好的自动补全能力,但是就未必知道 python 也同样可以 Tab 键补 ...

  3. hive 普通创建表和跟新列操作

    创建表 CREATE TABLE if not exists student ( student_id int, sex int, address String, email String ) 这里需 ...

  4. DTD文档模型和HTML基础

    html是超文本标记语言,现在常用到的2中文档格式是html5和XHTML 1.0 Transitiona(过渡). <!DOCTYPE html> <!--当前文档为html5-- ...

  5. Gamma校正与线性空间

    基础知识部分 为了方便理解,首先会对(Luminance)的相关概念做一个简单介绍.如果已经了解就跳到后面吧. 我们用Radiant energy(辐射能量)来描述光照的能量,单位是焦耳(J),因为光 ...

  6. B站开源ijkplayer 等多个项目

    弹幕视频网 Bilibili(B 站)近日在 GitHub 网站上建立了开源工作组(BOSTF),用以分享与维护自己的开源项目,其中包括 DanmakuFlameMaster(燃烧吧!烈焰弹幕使)与 ...

  7. Xcode 插件失效

    1.终端输入: 如果放在了应用程序里,就是这个: defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityU ...

  8. CodeForces Round#313

    第一题想当然了,结果被坑.. 有1的肯定能构成所有的其他数,没有1的肯定构不成1 ,这题T T #include <iostream> #include <cstring> # ...

  9. uva12545 Bits Equalizer

    uva12545 Bits Equalizer You are given two non-empty strings S and T of equal lengths. S contains the ...

  10. web Worker使js实现‘多线程’?

    大家都知道js是单线程的,在上一段js执行结束之前,后面的js绝对不会执行,那么为什么标题说js实现‘多线程’,虽然说加了引号,可是标题也不能乱写不是,可恶的标题党? 姑且抛开标题不说,先说我们经常会 ...