Fork me on GitHub

CentOS 6.7 下 PostgreSQL 9.5 的安装与配置

#yum方式安装(不同的系统版本对应的版本也不同)
yum install postgresql-server
#安装指定版本
yum install
https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm
yum install postgresql95-server postgresql95-contrib
#初始化PostgreSQL 数据库
service postgresql-9.5 initdb
# 设置开机启动服务
chkconfig postgresql-9.5 on
#重启数据库服务(PostgreSQL 数据库默认会创建一个postgres的数据库用户作为数据库的管理员,默认密码为空)
service postgresql-9.5 restart
#查询PostgreSQL的版本
psql --version
#修改数据库用户postgres的密码
# su - postgres
$ psql
# ALTER USER postgres WITH PASSWORD '123456';
# select * from pg_shadow;
#创建数据库
create database stockhq owner postgres;

#查看端口占用
netstat -anp |grep 5432
#开启远程访问
/var/lib/pgsql/9.5/data/postgresql.conf
修改
listen_addresses ='*'

/var/lib/pgsql/9.4/data/pg_hba.conf
修改
host all all  0.0.0.0/0 md5

CentOS7下安装

不同的linux os安装和版本不一样 拿centos来说 可以通过yum install postgresql-server安装,对应版本如下:

Distribution     Version
RHEL/CentOS/SL/OL 7     9.2
RHEL/CentOS/SL/OL 6     8.4(also supplies package postgresql92)
RHEL/CentOS/SL/OL 5     8.1 (also supplies package postgresql84)
Fedora 22     9.4
Fedora 21     9.3
Fedora 20     9.3

如果yum自带的版本不是自己想要的也可以去http://yum.postgresql.org/repopackages.php找想要的版本进行安装,
 
比如我要在centos 7 安装9.5-2的版本
yum install
https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm
yum install postgresql95-server postgresql95-contrib
#初始化库
/usr/pgsql-9.5/bin/postgresql95-setup initdb
#启动
systemctl enable postgresql-9.5.service
systemctl start postgresql-9.5.service
systemctl restart postgresql-9.5.service
#进入数据库(数据目录自动安装在/var/lib/pgsql/9.5/data)
su postgres
psql
#查看所有库
\l
#退出
\q
#停止firewall
systemctl stop firewalld.service
#禁止firewall开机启动
systemctl disable firewalld.service
#重启防火墙使配置生效
systemctl restart iptables.service
#设置防火墙开机启动
systemctl enable iptables.service

REFER:
https://github.com/sosedoff/pgweb
http://mirrors.163.com/
http://www.postgresql.org/download/linux/redhat/
PostgreSQL教程
http://www.yiibai.com/postgresql/
PostgreSQL 9.5 发布,带来 UPSERT 等新特性
http://www.oschina.net/news/69695/postgresql-9-5
CentOS7 PostgreSQL安装
http://www.cnblogs.com/tjpanda88/p/4306149.html
PostgreSQL,pgAdmin3 在Ubuntu上安装指南
http://www.cnblogs.com/eastday/archive/2013/05/31/3109819.html
PostgreSQL vs. MS SQL Server
http://www.oschina.net/translate/postgresql-vs-ms-sql-server
PostgreSQL [9.5.0] vs MariaDB [10.1.11] vs MySQL 性能比较
http://www.oschina.net/question/12_2151957
去 IOE,MySQL 完胜 PostgreSQL
http://www.oschina.net/news/61729/mysql-exceed-postgrsql
http://mp.weixin.qq.com/s?__biz=MjM5MjIxNDA4NA==&mid=204183537&idx=1&sn=846c7db66507ff486aafe1b721c0b56f#rd
一年后再看去IOE,MySQL vs PostgreSQL
http://www.innomysql.net/article/25581.html

posted @ 2016-03-16 14:23  花儿笑弯了腰  阅读(1959)  评论(0编辑  收藏  举报