星空网 > 软件开发 > 操作系统

Linux CentOS安装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 32bit

rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-6-i386/pgdg-centos94-9.4-1.noarch.rpm

CentOS 6.x 64bit

rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-1.noarch.rpm

CentOS 7 64bit

rpm -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_64postgresql94-server-9.4.1-1PGDG.rhel7.x86_64postgresql94-9.4.1-1PGDG.rhel7.x86_64postgresql94-contrib-9.4.1-1PGDG.rhel7.x86_64

五、初始化数据库

CentOS 6.x 系统

service postgresql-9.4 initdb

CentOS 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 startchkconfig postgresql-9.4 on

CentOS 7 系统

systemctl enable postgresql-9.4systemctl 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 restart

CentOS 7 系统

firewall-cmd --permanent --add-port=5432/tcpfirewall-cmd --permanent --add-port=80/tcpfirewall-cmd --reload

八、访问PostgreSQL

su - postgres

输出结果如下:

上一次登录:一 5月 18 15:17:29 CST 2015pts/0 上-bash-4.2$

输入命令psql将看到PostgrSQL的版本信息。

psql (9.4.1)输入 "help" 来获取帮助信息.

九、设置postgres用户密码

postgres=# \password postgres

Linux CentOS安装postgresql 9.4images/loading.gif' data-original="http://images0.cnblogs.com/blog2015/60890/201505/181622056355405.png" />

以上操作基本完成整个PostgreSQL的安装。




原标题:Linux CentOS安装postgresql 9.4

关键词:Centos

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

不“开车”不电商:亚马逊CPC优化的常见三大误区!:https://www.ikjzd.com/articles/97291
2019跨境电商父亲节营销,你想了解的都在这里:https://www.ikjzd.com/articles/97294
直击eBay大卖峰会:拥抱跨境电商趋势与新格局!:https://www.ikjzd.com/articles/97300
全额缴税也可能被关店?法国站VAT6月30日封号概率有多高?:https://www.ikjzd.com/articles/97302
亚马逊FBA发货常见问题!如何解决?:https://www.ikjzd.com/articles/97303
那些曾经的亚马逊大卖,现在还好吗?:https://www.ikjzd.com/articles/97304
长治婚庆女司仪和主持人:https://www.vstour.cn/a/366176.html
北京丰台区水上乐园哪家好玩?:https://www.vstour.cn/a/366177.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流