Welcome 微信登录

首页 / 数据库 / MySQL / Linux安装PostgreSQL 9.4

Linux安装PostgreSQL 9.4过程笔记,希望对大家有用。一、前言      PostgreSQL通常也简称Postgres,是一个关系型数据库管理系统,适用于各种Linux操作系统、Windows、Solaris、BSD和Mac OS X。PostgreSQL遵循PostgreSQL许可,是一个开源软件。PostgreSQL由PostgreSQL全球开发组开发,由极少数的公司志愿组成并进行监督管理,这些公司有红帽、EnterpriseDB等。      PostgreSQL的知名度越来越大,这是理所当然的:它是如此可靠、高效。与传统企业级关系型数据库相比,PostgreSQL完全基于社区驱动,有着丰富的工具和文档,形成了一个完善的生态系统。      目前搜索的大部分CentOS下安装均是用于Centos6.X的部分命令已经有很大变化,本文主要记录在Linux Centos 7.1下安装PostgreSQL的过程。二、安装PostgreSQL源CentOS 6.x 32bitrpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-6-i386/pgdg-centos94-9.4-1.noarch.rpmCentOS 6.x 64bitrpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-1.noarch.rpmCentOS 7 64bitrpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-1.noarch.rpm      在添加源的步骤中并没有太多的区别,主要是源的地址有一定的变化。三、执行安装命令yum updateyum install postgresql94-server postgresql94-contrib四、验证是否安装成功rpm -aq| grep postgres执行结果如下:postgresql94-libs-9.4.1-1PGDG.rhel7.x86_64
postgresql94-server-9.4.1-1PGDG.rhel7.x86_64
postgresql94-9.4.1-1PGDG.rhel7.x86_64
postgresql94-contrib-9.4.1-1PGDG.rhel7.x86_64五、初始化数据库CentOS 6.x 系统service postgresql-9.4 initdbCentOS 7 系统/usr/pgsql-9.4/bin/postgresql94-setup initdb如果我在CentOS 7下执行 service postgresql-9.4 initdb 将会报如下问题The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.六、启动服务并设置为开机启动CentOS 6.x 系统service postgresql-9.4 start
chkconfig postgresql-9.4 onCentOS 7 系统systemctl enable postgresql-9.4
systemctl start postgresql-9.4七、开放防火墙端口CentOS 6.x 系统vi /etc/sysconfig/iptables按下I进入输入模式,在文件中加入一下语句-A INPUT -m state --state NEW -m tcp -p tcp --dport 5432 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT输入完成后按ESC退出编辑模式,输入:wq退出VI编辑界面。重启防火墙服务service iptables restartCentOS 7 系统firewall-cmd --permanent --add-port=5432/tcp
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --reload八、访问PostgreSQLsu - postgres输出结果如下:上一次登录:一 5月 18 15:17:29 CST 2015pts/0 上
-bash-4.2$输入命令psql将看到PostgrSQL的版本信息。psql (9.4.1)
输入 "help" 来获取帮助信息.九、设置postgres用户密码postgres=# password postgres以上操作基本完成整个PostgreSQL的安装。------------------------------------华丽丽的分割线------------------------------------CentOS 6.3环境下yum安装PostgreSQL 9.3 http://www.linuxidc.com/Linux/2014-05/101787.htmPostgreSQL缓存详述 http://www.linuxidc.com/Linux/2013-07/87778.htmWindows平台编译 PostgreSQL http://www.linuxidc.com/Linux/2013-05/85114.htmUbuntu下LAPP(Linux+Apache+PostgreSQL+PHP)环境的配置与安装 http://www.linuxidc.com/Linux/2013-04/83564.htmUbuntu上的phppgAdmin安装及配置 http://www.linuxidc.com/Linux/2011-08/40520.htmCentOS平台下安装PostgreSQL9.3 http://www.linuxidc.com/Linux/2014-05/101723.htmPostgreSQL配置Streaming Replication集群 http://www.linuxidc.com/Linux/2014-05/101724.htm如何在CentOS 7/6.5/6.4 下安装PostgreSQL 9.3 与 phpPgAdmin  http://www.linuxidc.com/Linux/2014-12/110108.htm------------------------------------华丽丽的分割线------------------------------------PostgreSQL 的详细介绍:请点这里
PostgreSQL 的下载地址:请点这里本文永久更新链接地址